예제 #1
1
 public function __construct($username, $password, $debug = false)
 {
     parent::__construct($username, $password, $debug);
     $this->client = new TwitterApiClient(new MockTwitterApiServer());
     $this->client->setUsername($username);
     $this->client->setPassword($password);
 }
예제 #2
0
 public function testSearch()
 {
     $search_terms = $this->twitter_bot->getSearchTerms();
     $search_string = TwitterBot::formatSearchString($search_terms);
     $search_results = $this->twitter_bot->search(urlencode($search_string));
     foreach ($search_results->results as $tweet) {
         $this->assertContains('hockey', trim(strtolower($tweet->text)));
     }
 }
예제 #3
0
파일: list.php 프로젝트: kohlhofer/Mindmeto
require_once MINDMETO_ROOT . 'inc/oauth/twitterOAuth.php';
require_once MINDMETO_ROOT . 'inc/reminder.php';
require_once MINDMETO_ROOT . 'inc/twitter/bot.php';
$content = NULL;
$oauthState = $_SESSION['oauthState'];
$oauthSessionToken = $_SESSION['oauthRequestToken'];
$oauthToken = $_REQUEST['oauthToken'];
$section = $_REQUEST['section'];
if (!$session->loggedIn) {
    if (isset($_REQUEST['oauth_token']) && $_SESSION['oauthState'] == 'start') {
        $_SESSION['oauthState'] = $oauthState = 'returned';
    }
    handleTwitterAuthentication($oauthState);
}
if ($session->loggedIn) {
    $bot = new TwitterBot();
    $reminders = $bot->reminder;
    if (isset($_POST['command'])) {
        $commandResponse = $bot->parseCommand("web", $session->userDetails['user_twitter_data']->id, $_POST['command']);
        $queryResult = NULL;
        if ($commandResponse !== false) {
            $queryResult = $commandResponse;
            $session->userDetails = $db->fetchUserDetails($session->userId);
        } else {
            $reminderResult = $bot->parseReminder("web", $_POST['command'], $session->userId, -1);
            if ($reminderResult !== false) {
                $queryResult = $reminderResult;
            }
        }
    }
    $existingReminders = $reminders->fetch($session->userId);
예제 #4
0
파일: cron.php 프로젝트: kohlhofer/Mindmeto
<?php

define('MINDMETO_ROOT', 'public_html/');
require MINDMETO_ROOT . 'inc/db.php';
require MINDMETO_ROOT . 'inc/twitter/bot.php';
$bot = new TwitterBot();
switch ($argv[1]) {
    case 'reminders':
        $bot->sendUpcomingReminders();
        break;
    case 'email':
        $bot->collectNewFollowers();
        break;
    case 'dm':
        $bot->collectNewDMs();
        break;
    case 'replies':
        $bot->collectNewReplies();
        break;
    case 'ticker':
        /* Fetch the latest reminder data, convert it to a JSON object
           and then save it to a cache */
        $reminder = new Reminder();
        $options = new OptionsHandler();
        $reminderData = array();
        $lastId = $options->getValue('last_ticker_id');
        $latestPublicReminders = $reminder->fetchLatestPublic($lastId);
        if ($latestPublicReminders) {
            $i = 0;
            $latestId = $lastId;
            while ($reminderData = $latestPublicReminders->getRow()) {
<?php

/**
 * twitter_php_bot.php
 *
 * Authenticate to twitter, and follow users based on search parameter. 
 * A twitter "bot" if you will. Evil I suppose. So don't use it if that's what you believe.
 * 
 * @author joe fearnley
 * @date 01/20/2010
 * 
 */
require_once 'twitter/TwitterBot.php';
$username = '';
$password = '';
$search_terms = array('');
$twitter_bot = new TwitterBot($username, $password, $search_terms);
$twitter_bot->init();
echo "\n\nYou are now following " . $twitter_bot->getNumberOfFollowees() . " twitter users.\n\n";