把杀毒软件暂时关闭重试
分类 APP 下的文章
把杀毒软件暂时关闭重试
{"errcode":40001,"errmsg":"invalid credential, access_token is invalid or not latest, hints: [ req_id: SiLDHzyFe-4YxG9a ]"}这个错误提示很明显吧,提示说token 错误或失效
我研究了研究,没问题呀
得到openid 和 access_token这两个值,就判断用户是否真的登录了,这两个值也是立马得到立马拿去验证了,不会吧
地址:
https://api.weixin.qq.com/sns/auth
$params = "access_token=".$access_token."&openid=".$openid."&lang=zh_CN";
$url = "https://api.weixin.qq.com/sns/auth?".$params;
应该也没有问题呀!
那问题是出在哪呢!这可急死人了,找了一大堆
改了地址:https://api.weixin.qq.com/sns/userinfo(获取用户详细信息)
其实都一样的,我都拿到了openid,只需要验证一下就好了
最后忙了一个下午,才发现,我是封装了一个办法,把$access_token,$openid这两个参数传反了
最后附上代码
api代码(PHP)
public static function weixinUserCheck($openid,$access_token){
$params = "access_token=".$access_token."&openid=".$openid."&lang=zh_CN";
$url = "https://api.weixin.qq.com/sns/auth?".$params;
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, $url);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true) ;
curl_setopt($curl, CURLOPT_BINARYTRANSFER, true) ;
curl_setopt($curl, CURLINFO_HEADER_OUT, true);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, FALSE);
// 执行
$data = curl_exec($curl);
curl_close($curl);
return json_decode($data,true);
}
app端代码
getuserinfoh5appwx: function(){
let thisApp = this;
uni.showLoading({
title: '数据加载中',
mask: false
});
uni.login({
success:function(loginRes){
console.log(1,loginRes);
uni.getUserInfo({
success:function(res){
let user = res.userInfo;
let data = {};
data.avatar = user.avatarUrl;
data.name = user.nickName;
data.sex = user.gender;
data.access_token = loginRes.authResult.access_token;
data.openid = loginRes.authResult.openid;
data.appToken = "weixinApp";
util.request('login',function(user){
thisApp.$Storage.setSelfUser(user,function(){
uni.hideLoading();
uni.switchTab({
url: '/pages/person/person'
});
});
},'post',data);
}
})
},
});
},
Hbuilder:
"portrait-primary": 竖屏正方向;
"portrait-secondary": 竖屏反方向,屏幕正方向按顺时针旋转180°;
"landscape-primary": 横屏正方向,屏幕正方向按顺时针旋转90°;
"landscape-secondary": 横屏方向,屏幕正方向按顺时针旋转270°;
"portrait": 竖屏正方向或反方向,根据设备重力感应器自动调整;
"landscape": 横屏正方向或反方向,根据设备重力感应器自动调整;
解除锁定屏幕方向
void plus.screen.unlockOrientation();
weex(但这只在boat轻舟中有用):
一、安装调试
参考地址:
https://weex.apache.org/cn/guide/set-up-env.html
https://blog.csdn.net/xingxtao/article/details/79505997
npm 安装
$ npm install -g cnpm --registry=https://registry.npm.taobao.org
$ cnpm install -g weex-toolkit
初始化
$ weex create awesome-project
运行
////npm run dev & npm run serve
添加 Android 或 iOS 平台:weex platform add android 或 weex platform add ios
在android上运行 weex run android
二、ui
UI地址:https://alibaba.github.io/weex-ui/#/?id=weex-ui
安装配置文档:https://alibaba.github.io/weex-ui/#/cn/with-weex-toolkit
一、确保 weex-toolkit 为新版本
npm install -g weex-toolkit@latest
错误就使用中国镜像:
cnpm install -g weex-toolkit@latest
二、使用 weex-toolkit 创建一个项目
weex create your_project
npm i
三、安装 weex-ui
npm i weex-ui@latest -S
四、安装babel-preset-stage-0 和 babel-plugin-component 插件,前者用于babel编译,后者用于优化 weex-ui 包的组件引用
npm i babel-plugin-component babel-preset-stage-0 -D