Get the App
SLTechnology News&Howtos  ›  Development  › 

How to add menus to Wechat by php

Shulou Source: shulou.com Published: 2022-06-02 15:53:46 10月03日 Update

This article mainly explains "php how to add menus to Wechat", interested friends may wish to have a look. The method introduced in this paper is simple, fast and practical. Next, let the editor take you to learn how to add menus to Wechat by php.

Php realizes the method of adding menus to Wechat: 1. Obtain appid and appsecret;2 through Wechat public account, obtain access_token;3 through the API for obtaining credentials, and create a custom menu through the "function createMenu ($data) {...}" method.

This article operating environment: windows7 system, PHP7.1 version, DELL G3 computer

How does php add menus to Wechat?

An example of the method of creating Wechat custom menu with PHP implementation

The details are as follows:

Before using the universal interface, you need to do the following two steps:

1. Have a Wechat public account and get appid and appsecret (apply for internal test qualification on the public platform, which can be obtained after approval)

two。 Obtain the access_token through the API to obtain credentials

Note:

Access_token is a ticket for a third party to access api resources

Access_token corresponds to the official account is the globally unique ticket, repeated acquisition will invalidate the last acquired access_token.

Visit the following address (be careful to replace your appid and secret):

Https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid=APPID&secret=APPSECRET

Then you can see the return message in the browser:

{"access_token": "this is your access_token", "expires_in": 7200}

Create a custom menu:

Tags: Menu public method interface content voucher bill account learning practical deeper information global interest address practicality practicality that is platform easy to operate Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Shulou Tech Info macOS Shulou Information Shulou Technology Huawei