コード例 #1
0
ファイル: Twitter.php プロジェクト: jenalgit/social-api
 /**
  * {@inheritdoc}
  *
  * @SuppressWarnings(PHPMD.ShortVariable)
  */
 public function getPostById($id)
 {
     $libService = $this->getLibService();
     $requestUrl = 'statuses/show/' . $id . '.json';
     try {
         $response = new Response($libService->request($requestUrl));
     } catch (\Exception $e) {
         $this->propogateException($e);
     }
     $parser = new TwitterParser($response);
     $parser->parseStatusesShow();
     return $parser->getFirstPost();
 }
コード例 #2
0
 public function testParseStatusesShow()
 {
     // Get sample response
     $sampleResponse = $this->sampleResponses['get-statuses-show-id.json'];
     $response = new Response($sampleResponse, 'json');
     // Get parser
     $parser = new TwitterParser($response);
     // Parse data
     $parser->parseStatusesShow();
     // Test post
     $post = $parser->getFirstPost();
     $this->assertInstanceOf('\\Evolution7\\SocialApi\\Entity\\Post', $post);
     // Test user
     $user = $parser->getFirstUser();
     $this->assertInstanceOf('\\Evolution7\\SocialApi\\Entity\\User', $post->getUser());
     $this->assertInstanceOf('\\Evolution7\\SocialApi\\Entity\\User', $user);
 }