使用Twitter API 1.1从搜索/推文中获取位置

时间:2014-05-04 02:27:12

标签: php twitter

按照教程后,我可以使用PHP检索推文。但该教程仅显示了如何显示名称和文本。我现在正试图显示附加到推文的地理位置(lat和lng)。我查看了在https://dev.twitter.com/docs/api/1.1/get/search/tweets显示的示例JSON,看看如何做到这一点。我正在尝试使用以下代码。

$results = $toa->get('search/tweets', $query);
foreach ($results->statuses as $result) {
if(!($result->geo===null)){
echo "$result->user->screen_name ."<br/>". $result->text . "<br/>".$result->geo;
}
}

但我收到以下错误

Catchable fatal error: Object of class stdClass could not be converted to string 

在$ result-&gt; geo的行上。 我应该如何使用$ result-&gt; geo来打印lat和lng。或者我应该使用任何其他属性来获取位置坐标?

我尝试使用$ result-&gt; user-&gt;位置,但我不确定这是发送推文的位置还是用户生物信息中的位置。我认为它是生物信息。我需要发布推文的位置。

0 个答案:

没有答案