当前位置: 首页>>代码示例>>PHP>>正文


PHP TwitterOAuth::getLastBody方法代码示例

本文整理汇总了PHP中Abraham\TwitterOAuth\TwitterOAuth::getLastBody方法的典型用法代码示例。如果您正苦于以下问题:PHP TwitterOAuth::getLastBody方法的具体用法?PHP TwitterOAuth::getLastBody怎么用?PHP TwitterOAuth::getLastBody使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Abraham\TwitterOAuth\TwitterOAuth的用法示例。


在下文中一共展示了TwitterOAuth::getLastBody方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: provide

 /**
  * @param Article $article
  * @param string $header
  */
 public function provide(Article $article, $header = "")
 {
     $this->twitter->post("statuses/update", array("status" => "{$header} {$article->getTitle()} >> http://matomepp.net/p/{$article->getArticleId()}"));
     if ($this->twitter->getLastHttpCode() != 200) {
         throw new \RuntimeException(json_encode($this->twitter->getLastBody()));
     }
     $this->storeTweets($article);
 }
开发者ID:sat8bit,项目名称:matomepp,代码行数:12,代码来源:PickupTweetService.php

示例2: testResetLastResponse

 /**
  * @depends testLastResult
  */
 public function testResetLastResponse()
 {
     $this->twitter->resetLastResponse();
     $this->assertEquals('', $this->twitter->getLastApiPath());
     $this->assertEquals(0, $this->twitter->getLastHttpCode());
     $this->assertEquals(array(), $this->twitter->getLastBody());
 }
开发者ID:alexxnotfound,项目名称:twitter_bot,代码行数:10,代码来源:TwitterOAuthTest.php

示例3: send

 /**
  * Send Tweet through Twitter API
  *
  * @return Void
  */
 public function send()
 {
     /**
      * Initiate new Twitter
      */
     $twitter = new TwitterOAuth(env('CONSUMER_KEY'), env('CONSUMER_SECRET'), env('ACCESS_TOKEN'), env('ACCESS_SECRET'));
     /**
      * Get Tweets from Queue
      */
     $tweets = $this->next();
     /**
      * Collate Responses
      */
     $results = array();
     /**
      * Generate Images and Upload/Send each Tweet
      */
     foreach ($tweets as $tweet) {
         // Get Name
         $name = Admin::name($tweet->target);
         // Get Target Handle
         $target = Targets::find($tweet->target);
         $handle = $target->handle;
         // Remove Linebreaks from Message
         $tweet->message_clean = str_replace(array("\r", "\n"), ' ', $tweet->message_clean);
         if (trim($name) != '' && trim($tweet->message_clean != '')) {
             // Generate Image
             Image::setDetails($name, $tweet->message_clean);
             $image = Image::paintImage();
             $details = Image::saveImage($image);
             // Save Tweet with Image URL
             $tweet->image_url = $details['image_url'];
             $tweet->save();
             // The Message
             $hashtag = '#tweetthelove';
             $message = '@' . $handle . ' ' . $tweet->message_clean . ' ' . $hashtag;
             // Upload to Twitter
             $media = $twitter->upload('media/upload', ['media' => $details['image_url']]);
             if (isset($media->media_id_string)) {
                 // Post Tweet
                 $status = $twitter->post('statuses/update', ['status' => $message, 'media_ids' => $media->media_id_string]);
             }
             if ($twitter->getLastHttpCode() === 200) {
                 // Mark as Sent
                 $tweet->sent = 1;
                 $tweet->save();
                 $result = true;
             } else {
                 $tweet->failed = 1;
                 $tweet->save();
                 $result = json_encode($twitter->getLastBody());
             }
         } else {
             $tweet->failed = 1;
             $tweet->save();
             $result = false;
         }
         $results[$tweet->id] = array('status' => $result, 'message' => $message);
     }
     return $results;
 }
开发者ID:JamiePoole,项目名称:MyTwitterCrush,代码行数:66,代码来源:TweetHandler.php


注:本文中的Abraham\TwitterOAuth\TwitterOAuth::getLastBody方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。