qq_沐彡言_0
2017-10-26 16:52
public function http_curl($url){
$ch = curl_init();
curl_setopt($ch,CURLOPT_URL,$url);
curl_setopt($ch,CURLOPT_RETURNTRANSFER,1);
$output = curl_exec($ch);
curl_close($ch);
return json_decode($output,true);
}
//获取用户的openID
public function getBaseInfo(){
//1.获取到code
$appid="wxfbd13d9aff8a913a";
$redirect_uri=urlencode("119.23.239.149/home/Login/getUserOpenId");
$url="https://open.weixin.qq.com/connect/oauth2/authorize?appid=".$appid."&redirect_uri=".$redirect_uri."&response_type=code&scope=snsapi_base&state=123#wechat_redirect";
header("Location:$url");
}
public function getUserOpenId(){
//2.获取到网页授权的access_token
$appid="wxfbd13d9aff8a913a";
$code=input(code);
$appsecret="09d05919edad8d9cea72902bd91073de";
$url="https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid=$appid&secret=$appsecret";
$res=$this->http_curl($url);
//3.拉取用户的OPENDid
}
请问你最后解决了吗
PHP微信公众平台开发高级篇—网页授权接口
28430 学习 · 111 问题
相似问题