Ejemplo n.º 1
0
 public function fetchGeoPoints(ParametersInterface $parameters, $geoPoints = array())
 {
     $response = $this->api->get($this->buildSearchUrl(), $this->filterParameters($parameters));
     foreach ($response->statuses as $status) {
         // Majority of tweets do not have geotags, therefore we need to discard most of them
         if (is_null($status->geo)) {
             continue;
         }
         $geoPoint = new GeoPoint($status->geo->coordinates[0], $status->geo->coordinates[1], $status->text);
         $geoPoints[] = $geoPoint;
         $parameters->set('lastId', $status->id);
     }
     if (count($geoPoints) < $this->numberOfTweets) {
         $geoPoints = $this->fetchGeoPoints($parameters, $geoPoints);
     }
     return $geoPoints;
 }
Ejemplo n.º 2
0
 /**
  * Class constructor
  *
  * @return void
  */
 public function __construct()
 {
     $consumer_key = Config::get('services.twitter_oauth.consumer_key');
     $consumer_secret = Config::get('services.twitter_oauth.consumer_secret');
     $oauth_token = Session::get('twitter.oauth_token');
     $oauth_token_secret = Session::get('twitter.oauth_token_secret');
     return parent::__construct($consumer_key, $consumer_secret, $oauth_token, $oauth_token_secret);
 }
Ejemplo n.º 3
0
 /**
  * get last user tweets
  * @param string $consumerKey
  * @param string $consumerSecret
  * @param string $oauthToken
  * @param string $oauthTokenSecret
  * @param integer $userName
  * @param integer $count
  * @param boolean $excludeReplies
  * @param integer $lastTwitterPostId
  * @return array of user tweets
  */
 public static function getLastTweets($consumerKey, $consumerSecret, $oauthToken, $oauthTokenSecret, $userName, $count = 2, $excludeReplies = true, $lastTwitterPostId = null)
 {
     //get a valid twitter connection of user
     $connection = new TwitterOAuth($consumerKey, $consumerSecret, $oauthToken, $oauthTokenSecret);
     $parameters = array('exclude_replies' => $excludeReplies, 'screen_name' => $userName, 'count' => $count);
     if ($lastTwitterPostId) {
         $parameters['since_id'] = $lastTwitterPostId;
     }
     $data = @$connection->get('statuses/user_timeline', $parameters);
     //check if connection success with twitter
     if (200 == $connection->http_code) {
         //success
         return $data;
     }
     return array();
 }