1.第一步api
$hosturl = urlencode('');//異步回調地址 $wechatInfo = WechatInfo::get_wechat(); //查詢appid $url = "https://open.weixin.qq.com/connect/oauth2/authorize?appid={$wechatInfo['appid']}&redirect_uri={$hosturl}&response_type=code&scope=snsapi_base&state={$user['user_id']}#wechat_redirect"; $result = ['status' => 2, 'msg' => '登錄成功', 'data' => $user, 'url' => $url];
2.異步回調地址app
$code = input('code'); $user_id = input('state'); $wechatInfo = WechatInfo::get_wechat(); $appid = $wechatInfo['appid']; $secret = $wechatInfo['appsecret']; $url = "https://api.weixin.qq.com/sns/oauth2/access_token?appid={$appid}&secret={$secret}&code={$code}&grant_type=authorization_code"; $sdk =Jssdk::curlGet($url);
有那些不明白的,能夠在評論裏留言,我會及時的回覆你們的curl