0

I am trying to create a search using the new API1.1 twitter. The feedback I'm getting with the search query is:

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]

And to try to show the results I am trying:

<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**

In the second example I get the following error: Notice: Undefined property: stdClass::$screen_name

Can you help me please.

Thank you.

2 Answers2

0

I haven't tested this but screen_name looks like it is a property of the user object so try:

$tweet->user->screen_name

Jeff S.
  • 1,201
  • 1
  • 14
  • 17
  • Hello thanks for the feedback, I tried this way but it appeared the error below: Notice: Undefined property: stdClass::$user – Henrique Soares da Silva Jul 26 '13 at 14:25
  • I think I would need to see the complete code example to help further. What does print_r($tweet) give you? – Jeff S. Jul 27 '13 at 04:35
  • Sorry for the delay stdClass Object ( [statuses] => Array ( [0] => stdClass Object ( [metadata] => stdClass Object ( [result_type] => recent [iso_language_code] => en ) [created_at] => Mon Jul 29 22:41:14 +0000 2013 [id] => 3.6197975966156E+17 [id_str] => 361979759661563907 [text] => User Error and the Mobiüs FAQ #FreeBandNames [source] => HootSuite [truncated] => [in_reply_to_user_id_str] => [in_reply_to_screen_name] => [user] => stdClass Object ( [id] => 14093834 [id_str] => 14093834 [name] => Chas Hoppe [screen_name] => choppyrocks [location] , etc... – Henrique Soares da Silva Jul 30 '13 at 11:30
0

I managed to solve the problem. Was missing at the time of making the loop to bring the result.

wrong code

foreach($content->statuses as $tweetnter

correct code

foreach($content->statuses as $tweet

Thank´s