westhack / oauthsdk Goto Github PK
View Code? Open in Web Editor NEW第三方登录SDK
第三方登录SDK
我的配置
//腾讯微信配置
'WECHAT' => array(
'APP_KEY' => '123456', //应用注册成功后分配的 APP ID
'APP_SECRET' => '9cc9ac2fb17d010104d8a58dbebb4d3a', //应用注册成功后分配的KEY
'AUTHORIZE' => 'snsapi_userinfo',
'CALLBACK' => 'http://www.example.com/callback.php?type=wechat',//回调URL
)
sdk/WechatSDK.php
/**
* 获取request_code的额外参数,可在配置中修改 URL查询字符串格式
* @var srting
*/
protected $authorize = 'scope=snsapi_login';
/** * 获取用户信息 * @return array||bool * @throws \Exception */ public function getUserInfo(){ $params['uid'] = $this->openid(); $response = $this->call('users/show',$params); if ($response['ret'] == 0) { $userInfo['openid'] = $this->openid(); $userInfo['username'] = $response['screen_name']; $userInfo['avatar'] = $response['profile_image_url']; $userInfo['sex'] = $response['gender']=='m'?1:2; return $userInfo; } else { return false; } }
if ($response['ret'] == 0) {
应该改为:
if ($response['error_code'] == 0) {
OauthSDK/src/sdk/WechatSDK.php
Line 169 in 9411da2
通过var_dump($response), 可以看到有unionid.
code 换取 session_key
这是一个 HTTPS 接口,开发者服务器使用登录凭证 code 获取 session_key 和 openid。
session_key 是对用户数据进行加密签名的密钥。为了自身应用安全,session_key 不应该在网络上传输。
接口地址:
https://api.weixin.qq.com/sns/jscode2session?appid=APPID&secret=SECRET&js_code=JSCODE&grant_type=authorization_code
这个小程序登录是否也可以直接封装到SDK中?
😂😂
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.