0

我正在尝试使用新的 API1.1 twitter 创建搜索。我通过搜索查询得到的反馈是:

stdClass Object ( [statuses] => Array ( [0] => stdClass Object ( [metadata] => stdClass Object ( [result_type] => recent [iso_language_code] => en ) [created_at] => Thu Jul 25 18:47:29 +0000 2013 [id] => 3.6047138122329E+17 [id_str] => 360471381223288832 [text] => RT @mccv: Satan's Salad Spinner #freebandnames [source] => Twitter for Android [truncated] => [in_reply_to_status_id] => [in_reply_to_status_id_str] => [in_reply_to_user_id] => [in_reply_to_user_id_str] => [in_reply_to_screen_name] => [user] => stdClass Object ( [id] => 16124537 [id_str] => 16124537 [name] => Carlos A. Becker [screen_name] => caarlos0 [location] => Joinville - SC [description]

并尝试显示我正在尝试的结果:

<span class="timestamp tw_timestamp">'.date('d M / H:i',strtotime($tweet->created_at)).'</span>  **--> Show OK**

<span class="username tw_username">@'.$tweet->screen_name.'</span> **--> Not OK**

在第二个示例中,我收到以下错误:注意:未定义属性:stdClass::$screen_name

你能帮我吗。

谢谢你。

4

2 回答 2

0

我没有对此进行测试,但 screen_name 看起来它是用户对象的属性,因此请尝试:

$tweet->user->screen_name

于 2013-07-26T03:17:50.093 回答
0

我设法解决了这个问题。在制作循环以带来结果时丢失。

错误代码

foreach($content->statuses as $tweetnter

正确的代码

foreach($content->statuses as $tweet

谢谢

于 2013-07-30T11:44:54.917 回答