Example #1
0
function getMsg($url)
{
    if (function_exists("file_get_contents")) {
        $result = getFileGetContent($url);
        return $result;
    } else {
        $result = getCatch($url);
    }
    return $result;
}
Example #2
0
    //p($arr_result);
    //exit;
    //	echo $arr_result['refresh_token'];
    // echo "<br />"."===============================刷新后的access_token相关信息==========step3================================"."<br />";
    /*define("REFRESH_TOKEN", $arr_result['refresh_token']);
       $refresh_access_token_url = "https://api.weixin.qq.com/sns/oauth2/refresh_token?appid=".APPID."&grant_type=refresh_token&refresh_token=".REFRESH_TOKEN;
     	$new_access_token_by_refresh_json = getCatch($refresh_access_token_url);
       $new_access_token_by_refresh_arr = json_decode($new_access_token_by_refresh_json, true); 
     	p($new_access_token_by_refresh_arr);// */
    //echo "<br />"."===============================刷新后的access_token相关信息结束==========step3================================"."<br />";
    // exit;
    //拉取用户信息(需scope为 snsapi_userinfo)  step4
    define("ACCESS_TOKEN", $arr_result['access_token']);
    //define("ACCESS_TOKEN", $new_access_token_by_refresh_arr['access_token']);
    $webPageUserInfoGet_url = "https://api.weixin.qq.com/sns/userinfo?access_token=" . ACCESS_TOKEN . "&openid=" . $arr_result['openid'];
    $userInfo_json = getCatch($webPageUserInfoGet_url);
    $userInfo_arr = json_decode($userInfo_json, true);
    //	p($userInfo_arr);
    //	exit;
    //获取132*132大小的图片链接地址
    $headimgurl = $userInfo_arr['headimgurl'];
    $headimgurl_tmpl = substr($headimgurl, 0, -1);
    $headimgurl = $headimgurl_tmpl . "132";
    //  exit;
    //p($userInfo_arr);
    // echo '<img src="'.$userInfo_arr["headimgurl"].'/">';
} else {
    echo "NO CODE";
}
?>
<!DOCTYPE html>