当curl吐出json时使用curl更新mysql

发布于 2024-10-14 15:41:11 字数 369 浏览 3 评论 0原文

好吧,这里有一个相当奇怪的问题(或者可能不是),

我试图使用curl从twitter中提取推文,这里是命令

curl http://stream.twitter.com/1/statuses/filter.json?track=XXhashtagXX -XXuserXX:XXpassXX

Everywhere有一个x,它是像twitter用户名和密码以及要查找的主题标签这样的变量的地方。

这是使用 twitter Restful api,每次进行更改时都会提醒您的脚本。

在控制台中,这个curl命令运行得很好,但现在我只需要获取输出并将其保存到我的mysql表中。

任何帮助将不胜感激。

Ok a rather strange question here (or maybe not)

I am trying to pull tweets out of twitter using curl here is the command

curl http://stream.twitter.com/1/statuses/filter.json?track=XXhashtagXX -XXuserXX:XXpassXX

Every where there is an x that is a place for variables like twitter username and password and also the hashtag to look for.

And this is using the twitter restful api which alerts your script everytime a change was made.

In a console this curl command works perfectly but now i just need to take the output and save it to my mysql tables.

Any help would be greatly appreciated.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

云柯 2024-10-21 15:41:11

现实生活中的朋友。这就是您非常想要的。

chmod a+x watch_twitter.sh
./watch_twitter.sh

sh watch_twitter.sh

watch_twitter.sh

#!/usr/bin/sh
nohup curl http://stream.twitter.com/1/statuses/filter.json?track=hashtag -uusername:password\!\! -o test.txt -N &
nohup php watch_test.php &
exit

watch_test.php

<?php
while(1){
        echo ".";
        $data = file_get_contents('test.txt');
        if($data){
                file_put_contents('test.txt',"");
                $dataarry = explode("\n",$data);
                foreach($dataarry as $data){
                        print_r(json_decode(trim($data)));
                }
                echo "FOUND SOMETHING!";
        }
        sleep(1);
}
print_r($data);
?>

IRL buddy. Here's what you want pretty much.

chmod a+x watch_twitter.sh
./watch_twitter.sh

or

sh watch_twitter.sh

watch_twitter.sh

#!/usr/bin/sh
nohup curl http://stream.twitter.com/1/statuses/filter.json?track=hashtag -uusername:password\!\! -o test.txt -N &
nohup php watch_test.php &
exit

watch_test.php

<?php
while(1){
        echo ".";
        $data = file_get_contents('test.txt');
        if($data){
                file_put_contents('test.txt',"");
                $dataarry = explode("\n",$data);
                foreach($dataarry as $data){
                        print_r(json_decode(trim($data)));
                }
                echo "FOUND SOMETHING!";
        }
        sleep(1);
}
print_r($data);
?>
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文