码迷,mamicode.com
首页 > 微信 > 详细

PHP获取微信 accesstoken

时间:2016-12-19 21:39:34      阅读:260      评论:0      收藏:0      [点我收藏+]

标签:需要   自己的   header   decode   公众   post   token   close   grant   

PHP根据appid和secret获取微信access_token,php通过curl远程获取微信access_token信息
微信公众号开启开发者模式,使用appid和secret请求微信获取accesstoken的接口路径,就可以了,

$appid = ‘wx422126b0b6bbfcfc‘;
$secret = ‘***‘;


$url = "https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid=" . $appid . "&secret=" . $secret . "";
$ch = curl_init();
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$result = curl_exec($ch);
curl_close($ch);
print_r(json_decode($result, true));

主要就只要整合到自己的项目中就可以了,accesstoken是只要使用微信公众号的话就需要的,写成方法整合一下就可以了

功能完成代码参考:http://www.erdangjiade.com/php/1007.html

PHP获取微信 accesstoken

标签:需要   自己的   header   decode   公众   post   token   close   grant   

原文地址:http://www.cnblogs.com/erdangjiade/p/6200460.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!