本文整理汇总了PHP中JSSDK::getPageUserInfo方法的典型用法代码示例。如果您正苦于以下问题:PHP JSSDK::getPageUserInfo方法的具体用法?PHP JSSDK::getPageUserInfo怎么用?PHP JSSDK::getPageUserInfo使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类JSSDK
的用法示例。
在下文中一共展示了JSSDK::getPageUserInfo方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: explode
$get = FALSE;
$req_uri = explode('/', $_SERVER["REQUEST_URI"], -1);
$req_uri = implode('/', $req_uri);
$jssdk = new JSSDK("wx2d39a6c422ad663c", "e339b975f47c4a16b2b4b41f10fb5ef1");
// 测试id
//$jssdk = new JSSDK("wxae45c193de06d5a4", "f9a61bd7a83a5302a9960a84eb9e8ba3");
global $user_class;
$user_info = new stdClass();
if (isset($_GET['code']) && isset($_GET['state']) && strlen($_GET['code']) == 32) {
$get = TRUE;
$code = sanitize_text_field($_GET['code']);
$state = sanitize_text_field($_GET['state']);
}
if ($get) {
//As long as we get here, there is no need to check
$user_info = $jssdk->getPageUserInfo($code);
if (!empty($user_info->openid)) {
// if successfully get the user information, then we are able to process.
$cookies->set("nickname", $user_info->nickname, 30, "days");
$cookies->set('user_id', $user_info->user_id, 30, "days");
$cookies->set('openid', $user_info->openid, 30, "days");
$cookies->set('city', $user_info->city, 30, "days");
$cookies->set('country', $user_info->country, 30, "days");
$cookies->set('headimgurl', $user_info->headimgurl, 30, "days");
$cookies->set('new_login', 1);
$string = $user_info->open_id . "oneu";
$ver_code = substr(md5($string), -9);
$cookies->set('ver_code_user_data', $ver_code, 30, "days");
$res = $user_class->set_user_info($user_info->openid, $user_info);
} else {
//relocated to the login page, to get code again.