1 Star 0 Fork 0

影子/carve

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
index.php 1.52 KB
一键复制 编辑 原始数据 按行查看 历史
影子 提交于 2018-12-25 19:22 +08:00 . 测试
<?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']]
);
?>
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/zhuanggitee/carve.git
git@gitee.com:zhuanggitee/carve.git
zhuanggitee
carve
carve
dev

搜索帮助