作者 景龙
1 个管道 的构建 通过 耗费 1 秒

调式微博登录

... ... @@ -22,6 +22,9 @@ class LoginController extends HomeBaseController
private $appkey = 737607150;//微博appkey
private $appsecret = 'd80b43a1e74e8ba095590b36a3459480';//微博appsecret
private $redirect_uri = 'http://www.xingqiu.cn/portal/login/wb_login';//回调地址
private $appkey1 = 'wx9cfa880272f186bf';//微信appkey
private $appsecret1 = '11b643393b1e54d6ef5eaa984ba4e545';//微信appsecret
//登录页面
public function login(){
return $this->fetch();
... ... @@ -348,15 +351,20 @@ class LoginController extends HomeBaseController
//第三方微信登录
public function wx_login(){
$config = Config::get('wx_login');
$app_id = $config['app_id'];
$redirect_uri = $config['redirect_uri'];
$scope = $config['scope'];
$state = md5(uniqid(rand(), TRUE));
$url = 'https://open.weixin.qq.com/connect/qrconnect?appid='.$app_id.'&redirect_uri='.$redirect_uri.'&response_type=code&scope='.$scope.'&state='.$state.'#wechat_redirect';
$code = $this->request->get('code');
$code = '021HoCq91Re1wP1g5Eo91Vgnq91HoCqd';
$url = 'https://api.weixin.qq.com/sns/oauth2/access_token?appid='.$this->appkey1.'&secret='.$this->appsecret1.'&code='.$code.'&grant_type=authorization_code';
$res = $this->http_get($url);
var_dump(11);
var_dump($res);exit;
$json_arr = json_decode($res,true);
// $token = $json_arr['access_token'];
$token = '22_LFufsKgmxT1jCtIuDJ7CLLwAOI7mOPlmNYHRHECuScIwrNZ3-Bmxj8pOjr2NZs7qdzH7iBkPddFtBdyVoBd7zas_gkQhDw3YJgm5iYa6d5w';
// $openid = $json_arr['openid'];
$openid = 'oYOYl5hbULoKimG5R8Uk-Paha0d8';
//通过access_token获取用户信息
$url1 = 'https://api.weixin.qq.com/sns/userinfo?access_token='.$token.'&openid='.$openid;
$res1 = $this->http_get($url1);
$json_arr1 = json_decode($res1,true);
var_dump($json_arr1);exit;
}
//第三方微博登录
... ... @@ -391,6 +399,9 @@ class LoginController extends HomeBaseController
$user = $this->findThird($where);
//获取微博id,昵称,头像
$userModel = new UserModel();
$ip = get_client_ip();
$users['last_login_time'] = time();
$users['last_login_ip'] = $ip;
if($user){
$users['user_nickname'] = $info['screen_name'];
$users['avatar'] = $info['profile_image_url'];
... ... @@ -424,8 +435,7 @@ class LoginController extends HomeBaseController
//取消授权
public function wb_cancel(){
echo '取消了';
// $this->redirect('/');
$this->redirect('/');
}
//查询第三方用户是否存在
... ...
... ... @@ -34,7 +34,7 @@
<!--登陆-->
<div class="login_right_main clearfix">
<div class="WeChat">
<a href=""><img src="__TMPL__/public/assets/starImg/aicon_89.png" alt=""></a>
<a href="https://open.weixin.qq.com/connect/qrconnect?appid=wx9cfa880272f186bf&redirect_uri=http://www.starplanet.cn/portal/login/wx_login&response_type=code&scope=snsapi_login&state=STATE#wechat_redirect"><img src="__TMPL__/public/assets/starImg/aicon_89.png" alt=""></a>
</div>
<form action="https://api.weibo.com/oauth2/authorize" method="POST" id="wb_form">
<div class="Sina" id="wb_login">
... ...
... ... @@ -197,6 +197,10 @@ $(function() {
window.open('http://v.t.sina.com.cn/share/share.php?' + temp.join('&'));
});
$('.weibo_share').click(function() {
$('#wb_share').submit();
});
//微博登录
$('#wb_login').click(function(){
$('#wb_form').submit();
... ... @@ -204,8 +208,8 @@ $(function() {
});
//点赞收藏
function operation(url, id = '') {
if (id == '') {
function operation(url, id) {
if (id == '' || id == undefined) {
var article_id = getUrlParam('id');
} else {
var article_id = $('#li_id').val();
... ...
... ... @@ -22,8 +22,14 @@
<p>168</p>
</div>
<!-- wb分享 -->
<div class="wb_go weibo">
<img src="__TMPL__/public/assets/starImg/bicon_05.png" alt="">
<p>168</p>
</div>
<form action="https://api.weibo.com/oauth2/authorize" method="POST" id="wb_share">
<div class="wb_go weibo_share">
<img src="__TMPL__/public/assets/starImg/bicon_05.png" alt="">
<p>168</p>
</div>
<input type="hidden" name="client_id" value="737607150">
<input type="hidden" name="redirect_uri" value="http://www.xingqiu.cn/portal/login/wb_login">
<input type="hidden" name="flag" value="1">
</form>
</div>
\ No newline at end of file
... ...
... ... @@ -264,8 +264,8 @@ function video_mask(msg) {
}, 6000);
}
//点赞收藏
function operation(url, id = '') {
if (id == '') {
function operation(url,id) {
if (id == '' || id == undefined) {
var article_id = getUrlParam('id');
} else {
var article_id = $('#li_id').val();
... ...