I am new to this PHP . I created a account in twitter api and manage to get the data from twitter in the JSON format and would like to extract the text and created_at fields from the JSOn but having no luck even after 3 days and final resort is this place.
My code till this 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 as $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 to build the 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 for 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
If does not work above one then try
instead of