How can I obtain the pre-authorization code of the open platform? Which url is entered for retrieval? Error: {code...} Code Section: {code...} How to obtain the pre-authorization code of the open platform? Which url is entered for retrieval?
Error:
array(2) { ["errcode"]=> int(41002) ["errmsg"]=> string(13) "appid missing" }
Code Section:
$ Ch = curl_init (); $ url = "https://api.weixin.qq.com/cgi-bin/component/api_component_token"; $ data = array ('component _ appid '=> $ APPID, 'component _ appsecret' => $ SECRET, 'component _ verify_ticket '=> $ ticket ['ticket']); $ data = http_build_query ($ data); // var_dump ($ data); $ ch = curl_init (); // open curl_setopt ($ ch, CURLOPT_POST, true); curl_setopt ($ ch, CURLOPT_RETURNTRANSFER, true); curl_setopt ($ ch, CURLOPT_URL, $ url); curl_setopt ($ ch, CURLOPT_POSTFIELDS, $ data); curl_setopt ($ ch, CURLOPT_SSL_VERIFYPEER, FALSE); curl_setopt ($ ch, CURLOPT_SSL_VERIFYHOST, FALSE); $ response = curl_exec ($ ch ); curl_close ($ ch); // close $ result = json_decode ($ response, true );
Reply content:
How can I obtain the pre-authorization code of the open platform? Which url is entered for retrieval?
Error:
array(2) { ["errcode"]=> int(41002) ["errmsg"]=> string(13) "appid missing" }
Code Section:
$ Ch = curl_init (); $ url = "https://api.weixin.qq.com/cgi-bin/component/api_component_token"; $ data = array ('component _ appid '=> $ APPID, 'component _ appsecret' => $ SECRET, 'component _ verify_ticket '=> $ ticket ['ticket']); $ data = http_build_query ($ data); // var_dump ($ data); $ ch = curl_init (); // open curl_setopt ($ ch, CURLOPT_POST, true); curl_setopt ($ ch, CURLOPT_RETURNTRANSFER, true); curl_setopt ($ ch, CURLOPT_URL, $ url); curl_setopt ($ ch, CURLOPT_POSTFIELDS, $ data); curl_setopt ($ ch, CURLOPT_SSL_VERIFYPEER, FALSE); curl_setopt ($ ch, CURLOPT_SSL_VERIFYHOST, FALSE); $ response = curl_exec ($ ch ); curl_close ($ ch); // close $ result = json_decode ($ response, true );
Appid missing
You have not defined the $ APPID variable
Yes. The problem of $ data value passing has been solved.
The same problem occurs. When passing the parameter, It is the error that the three parameters {"errcode": 41002, "errmsg": "appid missing"} are directly post before json format. Json_encode (['component _ appid '=>, 'component _ appsecret' =>, 'component _ verify_ticket '=>]);
$ Data to be submitted in JSON format