php的curl获取https加密协议请求返回json数据进行信息获取

WBOY
Release: 2016-06-23 13:58:00
Original
1067 people have browsed it

header("Content-type:text/html; charset=utf-8");
function getToken($url){
        $ch = curl_init(); 
curl_setopt($ch, CURLOPT_URL,$url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);   //相当关键,这句话是让curl_exec($ch)返回的结果可以进行赋值给其他的变量进行,json的数据操作,如果没有这句话,则curl返回的数据不可以进行人为的去操作(如json_decode等格式操作)
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); 
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false); 
return curl_exec($ch); 
//$row=curl_getinfo($ch, CURLINFO_HTTP_CODE);


}
$row=getToken("https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid=wxe7aae4182885340b&secret=1fd56a902800e30442611c1e3c792259");
$obj=json_decode($row);
echo $obj->access_token;

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!