<?php
/** 
 * UQ云商：	www.uqcms.com  
 * 联系QQ：	2200631718 
 * 可免费商用，需要留UQ云商链接作为交换，只首页底部留取即可，不影响使用。
 */
  class login_weibo { private static $uq0; public static function init() { if (is_null(self::$uq0)){ self::$uq0 = new self(); } return self::$uq0; } function __construct($uq1 = []) { $this->app_id = $uq1['app_key']??error_404('微博：app_key不能为空'); $this->app_secret = $uq1['app_secret']??error_404('微博：app_secret不能为空'); $this->state = $uq1['state']??''; $this->redirect_uri = cfg['site_domain'].'member/connback?alias=weibo'; } function jump_url() { $uq2 = 'https://api.weibo.com/oauth2/authorize?client_id='.$this->app_id.'&state='.$this->state.'&response_type=code&redirect_uri='.urlencode($this->redirect_uri); header("Location:".$uq2); } function get_token($uq3) { $uq2 = 'https://api.weibo.com/oauth2/access_token'; $uq4 = 'client_id='.$this->app_id.'&client_secret='.$this->app_secret.'&grant_type=authorization_code&redirect_uri='.urlencode($this->redirect_uri).'&code='.$uq3; $uq5 = curl::post($uq2, $uq4); $uq6 = json_decode($uq5); if(empty($uq6->error_code)){ $uq7['openid'] = $uq6->uid; $uq7['access_token'] = $uq6->access_token; return $uq7; }else{ return false; } } function get_access_token() { return $_SESSION['connect']['weibo']['access_token']; } function user_info($uq8, $uq9) { $uq2 = 'https://api.weibo.com/2/users/show.json?uid='.$uq9.'&access_token='.$uq8; $uq10 = curl::get($uq2); $uq11 = json_decode($uq10); $uq7['nick'] = $uq11->screen_name; $uq7['avatar'] = $uq11->avatar_large; $uq12 = array( 'm'=>'1', 'f'=>'0', ); $uq7['sex'] = $uq12[$uq11->gender]; return $uq7; } function oauth_info($uq8) { $uq13 = 'https://api.weibo.com/oauth2/get_token_info'; $uq4 = 'access_token='.$uq8; $uq10 = curl::post($uq13, $uq4); return json_decode($uq10); } function update($uq8, $uq14) { $uq13 = 'https://api.weibo.com/2/statuses/update.json'; $uq15 = 'status='.urlencode($uq14).'&access_token='.$uq8; $uq10 = curl::post($uq13,$uq15); return json_decode($uq10); } function upload($uq8, $uq14, $uq16) { $uq13 = 'https://upload.api.weibo.com/2/statuses/upload.json'; $uq7 = array( 'status'=>urlencode($uq14), 'access_token'=>$uq8, 'pic'=>'@F:/'.$uq16, ); $uq10 = curl::post($uq13,$uq7); return json_decode($uq10); } }