dongzj2015 2019-03-10 14:11
浏览 65

我怎么才能从这个数组中拉出5条推文?

How can I only pull an exact number of tweets such as 5? I have tried to use the count function but it's not working? Any suggestions would be appreciated, thank you :)

$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')");

}
}
?> 
  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 drone 推送镜像时候 purge: true 推送完毕后没有删除对应的镜像,手动拷贝到服务器执行结果正确在样才能让指令自动执行成功删除对应镜像,如何解决?
    • ¥15 求daily translation(DT)偏差订正方法的代码
    • ¥15 js调用html页面需要隐藏某个按钮
    • ¥15 ads仿真结果在圆图上是怎么读数的
    • ¥20 Cotex M3的调试和程序执行方式是什么样的?
    • ¥20 java项目连接sqlserver时报ssl相关错误
    • ¥15 一道python难题3
    • ¥15 牛顿斯科特系数表表示
    • ¥15 arduino 步进电机
    • ¥20 程序进入HardFault_Handler