Exemplo n.º 1
0
 public function testParseMedia()
 {
     // Get sample response
     $sampleResponse = $this->sampleResponses['get-media-media_id.json'];
     $response = new Response($sampleResponse, 'json');
     // Get parser
     $parser = new InstagramParser($response);
     // Parse data
     $parser->parseMedia();
     // Test post
     $post = $parser->getFirstPost();
     $this->assertInstanceOf('\\Evolution7\\SocialApi\\Entity\\Post', $post);
     $this->assertEquals('3', $post->getId());
     $this->assertNull($post->getBody());
     $this->assertEquals('image', $post->getMediaType());
     $this->assertEquals('//distillery.s3.amazonaws.com/media/2010/07/16/4de37e03aa4b4372843a7eb33fa41cad_7.jpg', $post->getMediaUrl());
     $dateTime = new \DateTime();
     $dateTime->setTimestamp(1279340983);
     $this->assertEquals($dateTime, $post->getCreated());
     // Test user
     $user = $post->getUser();
     $this->assertInstanceOf('\\Evolution7\\SocialApi\\Entity\\User', $user);
     $this->assertEquals('3', $user->getId());
     $this->assertEquals('kevin', $user->getHandle());
     $this->assertEquals('http://instagram.com/kevin', $user->getUrl());
     $this->assertEquals('Kevin S', $user->getName());
     $this->assertEquals('...', $user->getImageUrl());
 }
Exemplo n.º 2
0
 /**
  * {@inheritdoc}
  *
  * @SuppressWarnings(PHPMD.ShortVariable)
  */
 public function getPostById($id)
 {
     $libService = $this->getLibService();
     $requestUrl = 'media/' . $id;
     try {
         $response = new Response($libService->request($requestUrl));
     } catch (\Exception $e) {
         $this->propogateException($e);
     }
     $parser = new InstagramParser($response);
     $parser->parseMedia();
     return $parser->getFirstPost();
 }