2014-08-28 17 views
0

我使用PHP和HTML開發簡單的Twitter API交互。我正在使用使用Twitter API僅返回PHP中選定的數據

GET 
https://api.twitter.com/1.1/users/show.json?screen_name=rsarver 

命令。我只想返回用戶名,追隨者數量,以下數量和位置。

任何人都知道如何做到這一點?

<?php include "library/twitteroauth.php"; ?> 
<?php 
$consumer = "key"; 
$consumersecret = "key"; 
$accesstoken = "key"; 
$accesstokensecret = "key"; 

$twitter = new TwitterOAuth($consumer, $consumersecret, $accesstoken, $accesstokensecret); 
$tweets = $twitter->get('https://api.twitter.com/1.1/users/lookup.json?screen_name=bandstring'); 


?> 

<html> 
    <head> 
      <meta charset ="UTF-8" /> 
      <title>Twitter Search</title>  
    </head> 
     <body> 
      <form action="" method="post"> 
      <label>Search: <input type="text" name ="keyword"/> 
      </form> 
      <?php 
      if (isset($_POST['keyword'])){ 
       $tweets = $twitter->get('https://api.twitter.com/1.1/users/lookup.json?screen_name='.$_POST['keyword']. ''); 
         var_dump($tweets); 
        }   

      ?> 
     </body> 
</html> 
+0

檢查REST API文檔https://dev.twitter.com/docs/api/1.1 – 2014-08-28 11:54:46

+0

@RonniEgeriis我看不到任何提及的信息過濾。 – liamsheridann 2014-08-28 14:14:54

+0

然後在他們的API中不支持它。 – 2014-08-29 08:38:01

回答

0

該API不會過濾掉任何信息。您將收到您作爲JSON對象請求的信息,並且必須解析出您所需的信息。

+0

在PHP中執行此操作的命令是什麼? – liamsheridann 2014-08-28 16:02:34

+0

https://dev.twitter.com/docs/api/1.1/get/users/lookup – 2014-08-28 16:10:28