如何在我的数据库中存储带有特定主题标签的推文? [关闭]

I want to monitor and store all tweets with a hashtag '#myDDD' into my MySQL database. I want to store the username of the guy who tweeted, the content of the tweet and the timestamp. I have a table with 'username', 'tweet' and 'time'. Ideally I wouldn't want to get retweets.

Use this

<?php
function load_tweets($url) {
    $ch = curl_init();
    curl_setopt($ch,CURLOPT_URL,$url);
    curl_setopt($ch,CURLOPT_RETURNTRANSFER,1);
    curl_setopt($ch,CURLOPT_CONNECTTIMEOUT,5);
    return json_decode(curl_exec($ch));
    curl_close($ch);
}
$TwitterData = load_tweets("http://search.twitter.com/search.json?q=%23myDDD");
$DataYouWant = array();
foreach($TwitterData->results as  $value) {
        $DataYouWant[] = array( "tweet" => $value->text,
                                "username" => $value->from_user_name,
                                "time" => $value->created_at);
}
?>

You have the data you wanted in the $DataYouWant array, but you will probably insert the data to your databas inside the foreach block and get rid of the $DataYouWant array. BTW there is no tweets with the hashtag #myDDD so change it, otherwise you will not get anything back.