利用curl函数处理GET数据获取微信公众号的access_token

<?php
//处理GET数据
$appid="wx0cf1ae434525b3bc";//填写AppID   $secret="530d5915c163cce3073062e281a8b21c";//填写Secret $url = "https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid={$appid}&secret={$secret}"; $ch = curl_init();//初始化curl函数 curl_setopt($ch,CURLOPT_URL,$url);//GET方式抓取url curl_setopt($ch,CURLOPT_RETURNTRANSFER,1);//以文件流的方式输出 $a = curl_exec($ch);//将文件保存到变量$a $strjson=json_decode($a);//JSON解析 $access_token = $strjson->access_token;//获取access_token echo $access_token; ?>
原文地址:https://www.cnblogs.com/huangchuxian/p/4437149.html