public function poll() { if ($this->oAuthToken != null && $this->oAuthTokenSecret != null) { $twitterLib = new TwitterLib(CONSUMER_KEY, CONSUMER_SECRET); $twitterLib->setOAuthToken($this->oAuthToken); $twitterLib->setOAuthTokenSecret($this->oAuthTokenSecret); $tweets = $twitterLib->statusesUserTimeline(); $rtn = array(); foreach ($tweets as $tweet) { if (!$this->entryExists($tweet['id_str'])) { $rtn[] = $tweet['text']; $this->addEntry($tweet['id_str']); } } return $rtn; } }
$twit = null; foreach ($twitters as $twitter) { if ($twitter->name == $words[1]) { if ($twitter->checkPass($words[2])) { $twit = $twitter; } } } if ($twit === null) { send($sock, "PRIVMSG {$nick} :Name/Password Error!"); } else { $oauth_token = $twit->reqToken; $oauth_verifier = $words[3]; // get tokens try { $twitterLib = new TwitterLib(CONSUMER_KEY, CONSUMER_SECRET); $response = $twitterLib->oAuthAccessToken($oauth_token, $oauth_verifier); } catch (Exception $e) { exceptionHandler($e); } if (isset($response) && isset($response['oauth_token'])) { // Save data returned $twit->setTokens($response['oauth_token'], $response['oauth_token_secret']); $twit->setDetails($response['user_id'], $response['screen_name']); // Poll and eat it so we don't flood try { $twit->poll(); } catch (Exception $e) { exceptionHandler($e); } // Notify the user