This is my code:
$latesttweets = $twitterconn>get("https://api.twitter.com/1.1/statuses/user_timeline.json?screen_name=".$twitter_id."&count=".$limit);
foreach ( $latesttweets as $tweet ){
...
$text_url = $tweet->entities->urls[0]->url; // this line gives an error
// test
echo $text_url; // this line doesn't give an error
... code for display tweet ...
}
I'm trying to retrieve the url from the object:
"urls": [{
"url": "https:\/\/t.co\/XdXRudPXH5",
"expanded_url": "https:\/\/blog.twitter.com\/2013\/rich-photo-experience-now-in-embedded-tweets-3",
"display_url": "blog.twitter.com\/2013\/rich-phot\u2026",
"indices": [80, 103]
}],
as shown here.
The funny thing is, I've tried echoing and it works, except that the error Notice: Undefined offset: 0
and Notice: Trying to get property of non-object
which follows on the next line keeps appearing.
(Note: The same goes for all the other arrays in the urls
array. I'm kind of sure it's something to do with the ..->urls[0]->..
, but I see no other way.)
Am I doing something wrong?