function testTweetContent()
 {
     $test_content = bw_get_tweets('test');
     foreach ($test_content as $content) {
         $this->assertIsA($content->title, 'string');
         $this->assertIsA(bw_get_tweet_user($content->author), 'string');
         $this->assertIsA(bw_get_tweet_id($content->guid), 'string');
     }
 }
Beispiel #2
0
function bw_add_tweets()
{
    //set hashtag for query
    $hashtag = 'dhanswers';
    //retrieve tweets
    $tweets = bw_get_tweets($hashtag);
    //iterate through each tweet
    foreach ($tweets as $tweet) {
        //determine tweet text, author, and id
        $tweet_text = $tweet->title;
        $tweet_user = bw_get_tweet_user($tweet->author);
        $tweet_id = bw_get_tweet_id($tweet->guid);
        //ignore if tweet is already a topic, contains a mention (@whatever),
        //or if the tweeter is not a DHAnswers user.
        if (!bw_check_duplicate($tweet_id) && !bw_has_mention($tweet_text) && bw_is_user($tweet_user)) {
            //new topic and post from tweet
            bw_insert_tweet($tweet_user, $tweet_id, bw_get_title($tweet_text), $tweet_text, bw_get_tags($tweet_text));
        }
        //end if
    }
    //end foreach
}