Php always gets the WeChat official account access_token. what should I do?

Source: Internet
Author: User
Php always gets the public account access_token. what should I do? Who can help me? I can't get the access_token all the time. I can put this url in the browser and return it normally. for example, why can't I do anything?


Reply to discussion (solution)

What is the data returned by file_get and what error is prompted?

In fact, it is not recommended that you directly use file_get-contents
Curl is recommended.

What is the data returned by file_get and what error is prompted?


In IE browser, the returned value is normal, but I don't know why I used file_get to return null?

Use curl.

Use curl.



How to use it, like file_get-contents (http://www.bjp51.net) directly submit it



After I use this method to submit and return bool (false), what is my code wrong?

function _Curl($url) {$ch = curl_init();curl_setopt($ch, CURLOPT_TIMEOUT, 5);curl_setopt($ch, CURLOPT_URL, $url);curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);$dataBlock = curl_exec($ch);curl_close($ch);return $dataBlock;}

To use CURL, first determine whether you have installed curl to expand phpinfo () and check whether there is a curl module.
If yes, use get.
Function get_curl ($ url ){
$ Ch = curl_init ();
Curl_setopt ($ ch, CURLOPT_URL, $ url );
Curl_setopt ($ ch, CURLOPT_RETURNTRANSFER, 1 );
Curl_setopt ($ ch, CURLOPT_HEADER, 0 );
$ Return_get = curl_exec ($ ch );
Curl_close ($ ch );
Return $ return_get;
}

Have you installed curl?

I found the cause is a server problem.

Is there a problem with the server ??

I found it was a server problem. it would be nice to change the server.

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.