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


PHP TwitterOAuth::lastStatusCode方法代碼示例

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


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

示例1: authTwitter

 protected function authTwitter($save_name)
 {
     $config = $this->config;
     $conn = new TwitterOAuth($config['consumer_key'], $config['consumer_secret']);
     $request_token = $conn->getRequestToken();
     if ($request_token === false || $conn->lastStatusCode() != 200) {
         throw new RuntimeException("Error fetching Twitter auth token: Status code " . $conn->lastStatusCode() . '; ' . $conn->http_error);
     }
     $url = $conn->getAuthorizeURL($request_token);
     // Automatically send the user to the auth page.
     $ui = new UI();
     $ui->openBrowser($url);
     $pin = $ui->readline("Please visit {$url} then type the pin number: ");
     $conn = new TwitterOAuth($config['consumer_key'], $config['consumer_secret'], $request_token['oauth_token'], $request_token['oauth_token_secret']);
     $access_token = $conn->getAccessToken($pin);
     if ($access_token === false || $conn->lastStatusCode() != 200) {
         throw new RuntimeException("Error fetching Twitter access token: Status code " . $conn->lastStatusCode() . '; ' . $conn->http_error);
     }
     $this->config['oauth_token'] = $access_token['oauth_token'];
     $this->config['oauth_token_secret'] = $access_token['oauth_token_secret'];
     echo "Your Twitter token is " . $access_token['oauth_token'] . "\n";
     echo "Your Twitter token secret is " . $access_token['oauth_token_secret'] . "\n";
     echo "(Written to twitter-{$save_name}.txt)\n";
     if (file_put_contents("twitter-{$save_name}.txt", $access_token['oauth_token'] . "\n" . $access_token['oauth_token_secret'])) {
         return;
     }
     throw new RuntimeException("Failed to save oauth token to twitter-{$save_name}.txt");
 }
開發者ID:rabyunghwa,項目名稱:sslscrobbler,代碼行數:28,代碼來源:TwitterPlugin.php

示例2: sendTweet

 /**
  * Sends a tweet
  *
  * @param string $txt   the tweet text to send
  * @param bool   $limit DEPRECATED
  *
  * @return string URL of tweet (or false on failure)
  */
 public function sendTweet($txt, $limit = false)
 {
     if (!$this->authenticatedAsUser) {
         return false;
     }
     $resp = $this->api->post('statuses/update', array('status' => $txt));
     if (200 != $this->api->lastStatusCode()) {
         return false;
     }
     return $resp;
 }
開發者ID:phergie,項目名稱:phergie,代碼行數:19,代碼來源:twitter.class.php


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