Twitter API を使用して、ツイートのリツイート者を取得しています。コードには 2 つの For-Next ループが含まれており、理論的には機能します。私の問題は、以下のコードが「Request Limit Exceeded」の問題に対して脆弱であり、スクリプトを 3 回実行しようとしたときに、上記の制限エラーが発生したことです。
私はそれをすべて間違っているかもしれないので、アドバイス/コメントをお願いできますか?コードは以下のとおりです。
<?php
$urlUserTimeLine = 'https://api.twitter.com/1.1/statuses/user_timeline.json';
$getfield = '?count=200&screen_name=' . $AuthenticatedScreenName . '&since_id=' . $TweetID;
$requestMethod = 'GET';
$UserTimeLineResponse = $twitter->setGetfield($getfield)
->buildOauth($urlUserTimeLine, $requestMethod)
->performRequest();
$UserTimeLineResponseJSONDecoded = json_decode($UserTimeLineResponse, true);
foreach ($UserTimeLineResponseJSONDecoded as $key_post_to_url => $jsons_post_to_url) {
foreach ($jsons_post_to_url as $key_post_to_url2 => $jsons_post_to_url2) {
if($key_post_to_url2=="id"){
$TweetID2 = $jsons_post_to_url2;
$urlReTweets = 'https://api.twitter.com/1.1/statuses/retweets/' . $TweetID2 . '.json';
$ReTweeterResponse = $twitter->setGetfield($getfieldReTweets)
->buildOauth($urlReTweets, $requestMethodReTweets)
->performRequest();
$ReTweeterResponseJSONDecoded = json_decode($ReTweeterResponse, true);
foreach ($ReTweeterResponseJSONDecoded as $key_post_to_url => $jsons_post_to_url) {
foreach ($jsons_post_to_url['user'] as $key_post_to_url2 => $jsons_post_to_url2) {
if($key_post_to_url2=="screen_name"){
echo $jsons_post_to_url2;
}
}
}
}
}
}
?>