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); }
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))); } }
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);
<?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";