Twitter からの json フィードの各ツイートをループしています。コードの最初の部分は完全に機能します...
$screen_name = "BandQ";
$count = 10;
$urlone = json_decode(file_get_contents("http://api.twitter.com/1/statuses/user_timeline.json?include_entities=true&include_rts=false&screen_name=BandQ&count=".$count."&page=1"),true);
$urltwo = json_decode(file_get_contents("http://api.twitter.com/1/statuses/user_timeline.json?include_entities=true&include_rts=false&screen_name=BandQ&count=".$count."&page=2"),true);
$data = array_merge_recursive( $urlone, $urltwo);
// Output tweets
//$json = file_get_contents("http://api.twitter.com/1/statuses/user_timeline.json?include_entities=true&include_rts=false&screen_name=".$screen_name."&count=".$count."", true);
//$decode = json_decode($json, true);
$count = count($data); //counting the number of status
$arr = array();
for($i=0;$i<$count;$i++){
$text = $data[$i]["text"]." ";
$retweets = $data[$i]["text"]."<br>Retweet Count: ".$data[$i]["retweet_count"]. "<br>Favourited Count: ".$data[$i]["favorite_count"]."<br>".$data[$i]["entities"]["user_mentions"][0]["screen_name"]."<br>";
// $arr[] = $text;
$arr[] = $retweets;
}
// Convert array to string
$arr = implode(" ",$arr);
print_r($arr);
しかし、entities->user_mentions->screen_name を取得しようとすると、PHP がエラーをスローします...
Notice: Array to string conversion in C:\xampp\htdocs\tweets.php on line 29
Notice: Use of undefined constant user_mentions - assumed 'user_mentions' in C:\xampp\htdocs\tweets.php on line 29
Notice: Use of undefined constant screen_name - assumed 'screen_name' in C:\xampp\htdocs\tweets.php on line 29
その screen_name 値を取得するにはどうすればよいですか?
どうもありがとう