Ejemplo n.º 1
0
 /**
  * Tweet by optionally uploading media and updating status.
  *
  * @param Tweet $tweet
  */
 public function tweet(Tweet $tweet)
 {
     if ($tweet->getMedia() instanceof StreamInterface) {
         $tweet = $this->mediaUploader->upload($tweet);
     }
     $this->statusUpdater->update($tweet);
 }
Ejemplo n.º 2
0
 /**
  * Test giving a Tweet a media id allows you to get it.
  */
 public function testMediaIdSetGet()
 {
     $mediaId = rand();
     $mediaString = (string) $mediaId;
     $output = $this->fixture->withMediaId($mediaString);
     $this->assertSame($mediaId, $output->getMediaId());
     // Make sure other properties are not affected
     $this->assertNull($output->getMedia());
     $this->assertNull($output->getMessage());
     $this->assertSame(0, $this->fixture->getMediaId());
     $this->assertNull($this->fixture->getMessage());
     $this->assertNull($this->fixture->getMedia());
 }
Ejemplo n.º 3
0
 /**
  * Parse Guzzle response and add media data to return Tweet.
  *
  * @param Response $response
  * @param Tweet    $tweet
  *
  * @return Tweet
  */
 protected function handleResponse(Response $response, Tweet $tweet)
 {
     $bodyString = $response->getBody();
     $bodyJson = json_decode($bodyString);
     return $tweet->withMediaId($bodyJson->{'media_id'});
 }