protected request_with_uid ( $url, $uid_or_name, $page = false, $count = false, $cursor = false, $post = false, $params = [] ) |
public static function addWeiboUserInfo($user_id) { //微博是否已返回相应的信息 // $token = LuS::get() if (isset($_SESSION['token']) && !empty($_SESSION['token'])) { $data['uid'] = $_SESSION['token']['uid']; $data['user_id'] = $user_id; $db = self::_db(); $result_select_weibo = $db->where(array("uid" => $_SESSION['token']['uid']))->select(); //如果微博用户没有存在 if (!$result_select_weibo) { if (!self::$_config) { self::$_config = (require_once WEIBO_PATH . 'config/config.php'); } $c = new SaeTClientV2(self::$_config['WB_AKEY'], self::$_config['WB_SKEY'], self::$_config['WB_ACCESS_TOKEN']); $info = $c->request_with_uid('https://api.weibo.com/2/users/show.json', $_SESSION['token']['uid']); //取出相应的微博用户信息 // $info = json_decode( $info, true ); if (isset($info['screen_name']) && !empty($info['screen_name'])) { $data['screen_name'] = $info['screen_name']; $data['description'] = $info['description']; $data['location'] = $info['location']; $data['profile_image_url'] = $info['profile_image_url']; } $data['access_token'] = $_SESSION['token']['access_token']; $data['expires_in'] = $_SESSION['token']['expires_in']; //把微博用户信息存入weibo_userinfo表里 $data['uid'] = $_SESSION['token']['uid']; return $db->data($data)->insert(); } else { return true; } } else { return false; } }