在twitter中获取更多用户详细信息

时间:2016-10-24 17:24:41

标签: php twitter

我试图使用php从twitter获取用户的详细信息,我有这个工作代码:

  <?php
  require_once('TwitterAPIExchange.php');
  /** Set access tokens here - see: https://dev.twitter.com/apps/ **/
  $settings = array(
'oauth_access_token' => "",
'oauth_access_token_secret' => "",
'consumer_key' => "",
'consumer_secret' => ""
  );
  $url = "https://api.twitter.com/1.1/statuses/user_timeline.json";
  $requestMethod = "GET";
  if (isset($_GET['user'])) {$user = $_GET['user'];} else {$user = "";}
  if (isset($_GET['count'])) {$count = $_GET['count'];} else {$count = 1;}
  $getfield = "?screen_name=$user&count=$count";
  $twitter = new TwitterAPIExchange($settings);
  $string = json_decode($twitter->setGetfield($getfield)
  ->buildOauth($url, $requestMethod)
  ->performRequest(),$assoc = TRUE);
  if($string["errors"][0]["message"] != "") {echo "<h3>Sorry, there was a problem.</h3><p>Twitter returned the following error message:</p><p><em>".$string[errors][0]["message"]."</em></p>";exit();}
  foreach($string as $items)
{
    echo "Time and Date of Tweet: ".$items['created_at']."<br />";
    echo "Tweet: ". $items['text']."<br />";
    echo "Tweeted by: ". $items['user']['name']."<br />";
    echo "Screen name: ". $items['user']['screen_name']."<br />";
    echo "Followers: ". $items['user']['followers_count']."<br />";
    echo "Following: ". $items['user']['friends_count']."<br />";
}
  ?>

但我想更多地获取位置,生物,生日等等。怎么做?

0 个答案:

没有答案