代码拉取完成,页面将自动刷新
<?php
//扫码登录
include './sdk/We.class.php';
include './sdk/jssdk.php';
$jssdk = new JSSDK();
$signPackage = $jssdk->GetSignPackage();
$we = new We();
$at = isset($_GET['at'])?$_GET['at']:'index';
if($at=='index'){
if(empty($_GET['url'])){
// echo 'no url';exit;
}
$url = "http://api.mtaction.com/dian/Qm/carve/index.php?at=sq";
//获取微信授权链接
$wxurl = $we->get_authorize_url($url,1);
header('Location:'.$wxurl);
}else if($at=='sq'){
if($_GET['code']){
$code = $_GET['code'];
//授权获取
$res = $we->get_access_token($code);
if($res===false && empty($res['access_token'])){
echo '授权失败';exit;
}else{
if(empty($res['access_token'])){
header('Location: http://api.mtaction.com/dian/Qm/carve/index.php?at=index');exit;
}
//获取用户基本信息
$res_user = $we->get_user_info($res['access_token'],$res['scope']);
//记录session
// setcookie('access_token',$res['access_token'],time()+60*60*1000);
setcookie('openid',$res_user['openid'],time()+10*60*1000);
}
//header('Location: http://api.mtaction.com/dian/huaxing/index.html');
}else{
echo 'No Code';exit;
}
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>登陆成功</title>
<meta name="keywords" content="">
<meta name="Description" content="">
<meta name="viewport" content="width=device-width,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no" />
<?php
print_r([
'openid'=>$res_user['openid'],
'nickname'=>$res_user['nickname'],
'avatar'=>$res_user['headimgurl']]
);
?>
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。