我怎么只能提取准确数量的推文(例如5条)?我试图使用计数功能,但是不起作用?任何建议,将不胜感激,谢谢:)
$stwt = array('HarbourBridge','SyndeyBridge','bridgeclimb');
for($n = 0; $n < count($stwt); $n++){
$url = 'https://api.twitter.com/1.1/search/tweets.json';
$getfield = "?q=#'$stwt[$n]'&result_type=recent";
$requestMethod = 'GET';
$twitter = new TwitterAPIExchange($settings);
$data=$twitter->setGetfield($getfield)
->buildOauth($url, $requestMethod)
->performRequest();
$phpdata = json_decode($data, true);
//Loop through the status updates and print out the text of each
foreach ($phpdata["statuses"] as $status) {
echo("<p>" . $status["text"] . "</p>");
stwitter1 = (string)$status["text"];
$stwt = "SELECT * FROM STweets ";
mysqli_query($mysqli,"INSERT INTO STwitter(STweets)
VALUES ('$stwitter1')");
}
}
?>