wx_getopenid

$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‘];
}
时间: 2024-11-07 12:46:29

wx_getopenid的相关文章

wx_getopenid api

<?php $appid = "************"; $secret = "***********"; if (!isset ( $_GET ['code'] )) { $back_url = $_GET ['back_url']; if ($back_url) { $back_url_arr = parse_url ( $back_url ); $arr_allow_url = array ( 'hk.4vtk.com', 'open.weixin.