!--? php$htmlstr = get_html ("Https://api.weibo.com/oauth2/access_ token?client_id=1233847790&client_secret=c8ba38aa75acc3830fff1eeeb1538723&grant_type=authorization_code& redirect_uri=http://www.yuecong.top&code=55b811f959d2afb495056e7e73f5ba5b "), echo $htmlstr; function get_html ($url ) {$ch = Curl_init (); curl_setopt ($ch, curlopt_followlocation, true); curl_setopt ($ch, Curlopt_url, $url); curl_setopt ($ch, curlopt_timeout,120); curl_setopt ($ch, Curlopt_useragent, "mozilla/5.0 (Windows NT 6.1; WOW64) applewebkit/535.1 (khtml, like Gecko) chrome/14.0.835.202 safari/535.1 "); curl_setopt ($ch, Curlopt_returntransfer, 1);//302redirect curl_setopt ($ch, Curlopt_post, true);//use POST mode Curl_ Setopt ($ch, Curlopt_header, false); curl_setopt ($ch, Curlopt_returntransfer, 1); curl_setopt ($ch, Curlopt_ssl_ Verifypeer, false);//Trust HTTPS Certificate $content = curl_exec ($ch); Curl_close ($ch); return $content;} ?-->
I use localhost on my own computer to access the normal return value, but placed on the server and then go to the browser to display the 400badrequest
Reply content:
!--? php$htmlstr = get_html ("Https://api.weibo.com/oauth2/access_ token?client_id=1233847790&client_secret=c8ba38aa75acc3830fff1eeeb1538723&grant_type=authorization_code& redirect_uri=http://www.yuecong.top&code=55b811f959d2afb495056e7e73f5ba5b "), echo $htmlstr; function get_html ($url ) {$ch = Curl_init (); curl_setopt ($ch, curlopt_followlocation, true); curl_setopt ($ch, Curlopt_url, $url); curl_setopt ($ch, curlopt_timeout,120); curl_setopt ($ch, Curlopt_useragent, "mozilla/5.0 (Windows NT 6.1; WOW64) applewebkit/535.1 (khtml, like Gecko) chrome/14.0.835.202 safari/535.1 "); curl_setopt ($ch, Curlopt_returntransfer, 1);//302redirect curl_setopt ($ch, Curlopt_post, true);//use POST mode Curl_ Setopt ($ch, Curlopt_header, false); curl_setopt ($ch, Curlopt_returntransfer, 1); curl_setopt ($ch, Curlopt_ssl_ Verifypeer, false);//Trust HTTPS Certificate $content = curl_exec ($ch); Curl_close ($ch); return $content;} ?-->
I use localhost on my own computer to access the normal return value, but placed on the server and then go to the browser to display the 400badrequest
First Test a non-HTTPS link, such as a random URL (http://www.baidu.com), to see if you can get the content, if you can then test the https://www.baidu.com, at this time if there is a bad request. So the question should be the version of PHP that appears. Our system has encountered a similar problem, PHP upgrade from 5.2.27 to 5.3.35 this situation, non-HTTP normal, HTTPS problems. The problem is probably due to a conflict between PHP and the OpenSSL library. Our environment is CentOS.
Curlopt_ssl_verifypeer in the code should not be true?
URL there is no string stitching to see if there is a line break or something