PHP Curl get WeChat Public number Access_token instance of PHP

Source: Internet
Author: User
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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.