This article mainly introduces PHP curl to obtain the public number Access_token example, the need for friends can refer to the following
1. Development of the public number first to get Access_token, the server IP is now added to the whitelist in developer settings before running the code
Public Function Index () { $appId = ' WXD0E50FE967DCCCCC '; $appSecret = ' d7f6be12ce41b60ss0f45054 ';//virtual, do not use $url = "https://api.weixin.qq.com/cgi-bin/token?grant_type= Client_credential&appid= ". $appId." &secret= ". $appSecret; $ch = Curl_init ();//Initialize Curl curl_setopt ($ch, Curlopt_url, $url);//address to be accessed curl_setopt ($ch, Curlopt_ returntransfer,1); curl_setopt ($ch, Curlopt_ssl_verifypeer, false);//Skip Certificate Verification curl_setopt ($ch, Curlopt_ssl_verifyhost, false);// Check that the SSL encryption algorithm exists from the certificate $data = Json_decode (curl_exec ($ch)); if (Curl_errno ($ch)) { var_dump (Curl_error ($ch));//Error printing error message } var_dump ($data);//printing Information Curl_ Close ($ch);//Turn off Curl }
2. Acquired Access_token valid within 2 hours
Summarize
The above is a small part of the introduction of PHP curl to get the public number Access_token example, I hope that we have some help, if you have any questions please give me a message, small series will promptly reply to you. Thank you very much for the support of PHP Chinese network!
Articles you may be interested in:
PHP implementation Carousel Lottery algorithm share PHP instance
PHP tips for using Curl_multi to implement concurrent request methods
PHP Performance test Tool xhprof installation and usage details PHP tips