1

ここでかなり奇妙な質問をします(またはそうでないかもしれません)

curl を使用して Twitter からツイートを取得しようとしています。コマンドは次のとおりです。

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

Twitter のユーザー名やパスワードなどの変数と、検索するハッシュタグの場所である x があるすべての場所。

これは、変更が行われるたびにスクリプトに警告する twitter restful api を使用しています。

コンソールでは、この curl コマンドは完全に機能しますが、出力を取得して mysql テーブルに保存するだけです。

どんな助けでも大歓迎です。

4

1 に答える 1

1

IRLバディ。これがあなたがかなり欲しいものです。

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);
?>
于 2011-01-26T23:41:43.913 に答える