Esempio n. 1
0
 public function saveToken($token, $openid, $openkey, $login_account, $eno)
 {
     try {
         $openid = strtolower($openid);
         $access_token = $token["access_token"];
         $expire_in = $token["expires_in"];
         $refresh_token = $token["refresh_token"];
         //获取用户基本信息
         $client = new TencentClient(TencentOAuth::$client_id, TencentOAuth::$client_key, $openid, $access_token);
         $userinfo = $client->get_user_baseinfo();
         $id = SysSeq::GetSeqNextValue($this->conn, "we_weibo_account", "id");
         $sql = "insert into we_weibo_account (id,uid,access_token,expires_in,nick_name,user_name,appid,appkey,followers_count,favourites_count,created_at,verified,refresh_token,openid,openkey,head_url,owner_staff,type,eno) \n\t\t  \tvalues(?,?,?,date_add(now(),interval ? second),?,?,?,?,?,?,now(),?,?,?,?,?,?,?,?)";
         $params = array($id, $openid, $access_token, (int) $expire_in, $userinfo['nick'], $userinfo['name'], TencentOAuth::$client_id, TencentOAuth::$client_key, $userinfo['fansnum'], $userinfo['favnum'], $userinfo['isvip'] == '1' ? true : false, $refresh_token, $openid, $openkey, $userinfo['head'], $login_account, 'tencent', $eno);
         $this->conn->ExecSQL($sql, $params);
         return true;
     } catch (\Exception $e) {
         var_dump($e->getMessage());
     }
 }
 public function commitWeibo($blog_id, $reqnum = 20, $pagetime, $twitterid)
 {
     $result = array('returncode' => '0000', 'data' => null, 'msg' => '', 'err' => array());
     $da = $this->get("we_data_access");
     $user = $this->get('security.context')->getToken()->getUser();
     $TencentWeiboMgr = new TencentWeiboMgr($da);
     $token = $TencentWeiboMgr->getToken($uid, $user->eno);
     if ($token == null) {
         $result = array('returncode' => '0003', 'msg' => '令牌无效', 'err' => array());
         return $result;
     }
     $TencentClient = new TencentClient(TencentOAuth::$client_id, TencentOAuth::$client_key, $token['openid'], $token['access_token'], $token['refresh_token']);
     $re = $TencentClient->getCommitList($blog_id, $reqnum, $pageflag = '0', $pagetime, $twitterid);
 }