码迷,mamicode.com
首页 > 其他好文 > 详细

wx_getopenid

时间:2015-04-22 20:04:38      阅读:175      评论:0      收藏:0      [点我收藏+]

标签:

$appid = "wx25767979a61a2385";
$secret = "***********18";
if (! isset ( $_GET [‘code‘] )) {
        $local_url = "http://{$_SERVER [‘HTTP_HOST‘]}{$_SERVER[‘PHP_SELF‘]}";
        $local_url = urlencode ( $local_url );
        $sit = "https://open.weixin.qq.com/connect/oauth2/authorize?appid={$appid}&redirect_uri={$local_url}&response_type=code&scope=snsapi_base&state=1#wechat_redirect";
        header ( "Location:" . $sit );
} else {
    $code = $_GET [‘code‘];
    $url = "https://api.weixin.qq.com/sns/oauth2/access_token?appid=" . $appid . "&secret=" . $secret . "&code=" . $code . "&grant_type=authorization_code";
    $json = json_decode ( file_get_contents ( $url ), true );
    $openid=$json [‘openid‘];
}

 

wx_getopenid

标签:

原文地址:http://www.cnblogs.com/yutaoyao/p/4448167.html

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