0
点赞
收藏
分享

微信扫一扫

微信开发之网页授权(获取access_token和code)


1.我们首先在公众测试号那配置授权回调域名(注意不加http和Https):

微信开发之网页授权(获取access_token和code)_php

2.获取code

   在控制器写入以下代码:


public function index(){
$appid="wx4ff531ee8a470861";
$rediret_url=urlencode('http://wyzdjg.top/vote/index.php/home/index/getcode');
// $rediret_url=urlencode('http://www.baidu.com');
$url="https://open.weixin.qq.com/connect/oauth2/authorize?appid=$appid&redirect_uri=$rediret_url&response_type=code&scope=snsapi_userinfo&state=1#wechat_redirect";
header("location:".$url);
}
public function getcode(){
$code=$_GET['code'];
$json=$this->access_token($co


举报

相关推荐

0 条评论