如何在推文中获取照片链接

时间:2016-12-27 14:41:19

标签: php twitter

我希望得到附在推文中的照片链接 看到代码:

$url = "https://api.twitter.com/1.1/statuses/home_timeline.json";
$requestMethod = "GET";
if (isset($_GET['user'])) {
    $user = $_GET['user'];
} else {
    $user = "parsi_tweet";
}
if (isset($_GET['count'])) {
    $count = $_GET['count'];
} else {
    $count= "10";
}

$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: ".$items['created_at']."<br />";
    echo "TWEET: ". $items['text']."<br />";
    echo "BY: ". $items['user']['name']."<br />";
    echo "USERNAME: ". $items['user']['screen_name']."<br />";
}

我可以通过echo "TIME: ".$items['created_at']."<br />";获得推文的时间 通过echo "TWEET: ". $items['text']."<br />";获取推文文本以及您可以在代码中看到的更多信息。 但是如何才能获得附在推文中的照片链接?!或者我该如何查看&#34;这张推文是否使用照片?!或不?! 谢谢你的帮助

0 个答案:

没有答案