In the php user-defined menu, I applied for a public platform test account, which has passed verification before. after paying attention to it, I sent a message to the test account to get the correct response from the test account, the custom menu I want to implement now uses *** instead of the appid and secret of my test account. I did not see the custom menu in the test account. what is the problem? & L php custom menu
I have applied for a test account for the public platform. I have already passed the verification. after I followed the verification, I sent a message to the test account using my number to get the correct response from the test account, the custom menu I want to implement now uses *** instead of the appid and secret of my test account. I did not see the custom menu in the test account. what is the problem?
/**
* Wechat php test
*/
// Define your token
Define ("TOKEN", "weixin ");
$ Token_url = "https://api.weixin.qq.com/cgi-bin/token? Grant_type = client_credential & appid = *** & secret = ***";
$ Data = "{
"Button ":[
{
"Type": "click ",
"Name": "Today's songs ",
"Key": "V1001_TODAY_MUSIC"
},
{
"Type": "click ",
"Name": "Introduction to singers ",
"Key": "V1001_TODAY_SINGER"
},
{
"Name": "menu ",
"Sub_button ":[
{
"Type": "click ",
"Name": "hello word ",
"Key": "V1001_HELLO_WORLD"
},
{
"Type": "click ",
"Name": "Like Us ",
"Key": "V1001_GOOD"
}]
}]
}";
$ WechatObj = new wechatCallbackapiTest ();
$ WechatObj-> post ($ wechatObj-> get_access_token (), $ data );
Class wechatCallbackapiTest
{
Public function get_access_token (){
$ Json = http_request_json ($ token_url );
$ Data = json_decode ($ json, true );
If ($ data ['Access _ token']) {
Return $ data ['Access _ token'];
} Else {
Return "an error occurred while obtaining access_token ";
}
}
Public function http_request_json ($ url ){
$ Ch = curl_init ();
Curl_setopt ($ ch, CURLOPT_URL, $ url );
Curl_setopt ($ ch, CURLOPT_SSL_VERIFYPEER, false );
Curl_setopt ($ ch, CURLOPT_SSL_VERIFYHOST, false );
Curl_setopt ($ ch, CURLOPT_RETURNTRANSFER, 1 );
$ Result = curl_exec ($ ch );
Curl_close ($ ch );
Return $ result;
}
Public function post ($ access_token, $ jsonData ){
$ Ch = curl_init ("https://api.weixin.qq.com/cgi-bin/menu/create? Access_token = ". $ access_token );
Curl_setopt ($ ch, CURLOPT_POST, 1 );
Curl_setopt ($ ch, CURLOPT_CUSTOMREQUEST, "POST ");
Curl_setopt ($ ch, CURLOPT_POSTFIELDS, $ jsonData );
Curl_setopt ($ ch, CURLOPT_RETURNTRANSFER, true );
Curl_setopt ($ ch, CURLOPT_HTTPHEADER, array ('content-Type: application/json '));
$ Result = curl_exec ($ ch );
Curl_close ($ ch );
Return $ result;
}
}
?>
Share: More