本文整理汇总了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);
}
示例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());
}
示例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;
}