當前位置: 首頁>>代碼示例>>PHP>>正文


PHP TwitterOAuth::getAccessToken方法代碼示例

本文整理匯總了PHP中Abraham\TwitterOAuth\TwitterOAuth::getAccessToken方法的典型用法代碼示例。如果您正苦於以下問題:PHP TwitterOAuth::getAccessToken方法的具體用法?PHP TwitterOAuth::getAccessToken怎麽用?PHP TwitterOAuth::getAccessToken使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Abraham\TwitterOAuth\TwitterOAuth的用法示例。


在下文中一共展示了TwitterOAuth::getAccessToken方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: twitterCallback

 public function twitterCallback()
 {
     //echo "helloCallback";
     if (!empty($_GET['oauth_verifier']) && !empty($this->request->session()->read('oauth_token')) && !empty($this->request->session()->read('oauth_token_secret'))) {
         $connection = new TwitterOAuth($this->consumerKey, $this->consumerSecret, $this->request->session()->read('oauth_token'), $this->request->session()->read('oauth_token_secret'));
         $access_tokencredential = $connection->getAccessToken($_REQUEST['oauth_verifier'], $this->request->session()->read('oauth_token'));
         $uniqueOauthToken = $access_tokencredential['oauth_token'];
         $uniqueOauthTokenSecret = $access_tokencredential['oauth_token_secret'];
         $twitteroauth = new TwitterOAuth($this->consumerKey, $this->consumerSecret, $uniqueOauthToken, $uniqueOauthTokenSecret);
         $message = "Tweet From Panovus Team!";
         //$output = $twitteroauth->get('friends/list');
         //$output = $twitteroauth->post("statuses/update", array("status" => $message));
         //echo"<pre style='color:red'>";
         //print_r($output);
         //echo'</pre>';
         /*
         echo"<pre style='color:red'>";
         print_r($access_tokencredential);
         		echo "</pre>";
         */
         //return $output;
         $id = $this->Auth->user('partner_id');
         $partner = $this->Partners->get($id);
         $data = ["twitter_oauth_token" => $uniqueOauthToken, "twitter_oauth_token_secret" => $uniqueOauthTokenSecret];
         $partner = $this->Partners->patchEntity($partner, $data);
         //echo "<pre style='color:red'>";
         //print_r($partner);
         //echo "</pre>";
         if ($this->Partners->save($partner)) {
             $this->Flash->success('Token has been saved.');
             return $this->redirect(['controller' => 'PartnerCampaignEmailSettings']);
         } else {
             $this->Flash->error('The partner could not be saved. Please try again. If you continue to experience problems, please contact Customer Support.');
         }
     } else {
         //end if get
         $this->Flash->error('Authorization has failed!');
         return $this->redirect(['controller' => 'PartnerCampaignEmailSettings']);
     }
 }
開發者ID:franky0930,項目名稱:MarketingConnex,代碼行數:40,代碼來源:TwitterCallbackController.php

示例2: test

 function test()
 {
     if (!empty($_GET['oauth_verifier']) && !empty($_SESSION['oauth_token']) && !empty($_SESSION['oauth_token_secret'])) {
         // We've got everything we need
         // TwitterOAuth instance, with two new parameters we got in twitter_login.php
         $twitteroauth = new TwitterOAuth('YOUR_CONSUMER_KEY', 'YOUR_CONSUMER_SECRET', $_SESSION['oauth_token'], $_SESSION['oauth_token_secret']);
         // Let's request the access token
         $access_token = $twitteroauth->getAccessToken($_GET['oauth_verifier']);
         // Save it in a session var
         $_SESSION['access_token'] = $access_token;
         // Let's get the user's info
         $user_info = $twitteroauth->get('account/verify_credentials');
         // Print user's info
         print_r($user_info);
     } else {
         // Something's missing, go back to square 1
         redirect("client/");
         echo "missing";
         die;
         //header('Location: twitter_login.php');
     }
 }
開發者ID:patrickchiuco,項目名稱:restfulapi,代碼行數:22,代碼來源:Client.php


注:本文中的Abraham\TwitterOAuth\TwitterOAuth::getAccessToken方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。