twitter json formatting in php -


i new php . created account in twitter api , manage data twitter in json format , extract text , created_at fields json having no luck after 3 days , final resort place.

my code till time:

$tweets = $connection->get("https://api.twitter.com/1.1/search/tweets.json?q=verizon"); $encode =json_encode($tweets); $decode = json_decode($encode,true); foreach($decode $tweet) {   echo "{$tweet->text} {$tweet->created_at}\n"; } 

var_dump result:

  1 =>      object(stdclass)[34]       public 'metadata' =>          object(stdclass)[35]           ...       public 'created_at' => string 'wed jun 10 15:54:11 +0000 2015' (length=30)       public 'id' => float 6.0866345858697e+17       public 'id_str' => string '608663458586968064' (length=18)       public 'text' => string 'rt @fortunemagazine: .@elonmusk wants build comcast of outer space http://t.co/wuuanftznc http://t.co/3cs0zmd6ea' (length=119)       public 'source' => string '<a href="http://twitter.com/download/iphone" rel="nofollow">twitter iphone</a>' (length=82)       public 'truncated' => boolean false       public 'in_reply_to_status_id' => null       public 'in_reply_to_status_id_str' => null       public 'in_reply_to_user_id' => null       public 'in_reply_to_user_id_str' => null       public 'in_reply_to_screen_name' => null       public 'user' =>          object(stdclass)[36]           ...       public 'geo' => null       public 'coordinates' => null       public 'place' => null       public 'contributors' => null       public 'retweeted_status' =>          object(stdclass)[39]           ...       public 'is_quote_status' => boolean false       public 'retweet_count' => int 22       public 'favorite_count' => int 0       public 'entities' =>          object(stdclass)[56]           ...       public 'favorited' => boolean false       public 'retweeted' => boolean false       public 'possibly_sensitive' => boolean false       public 'lang' => string 'en' (length=2) 

try

echo $tweet->{1}->text 

if not work above 1 try

echo $tweet['1']['text'] 

instead of

$tweet->text 

Comments

Popular posts from this blog

javascript - gulp-nodemon - nodejs restart after file change - Error: listen EADDRINUSE events.js:85 -

Fatal Python error: Py_Initialize: unable to load the file system codec. ImportError: No module named 'encodings' -

javascript - oscilloscope of speaker input stops rendering after a few seconds -