public function callRequest(Query $query) { $usr = $this->get('security.context')->getToken()->getUser()->getUser(); $settings = array('oauth_access_token' => $usr->getToken(), 'oauth_access_token_secret' => $usr->getSecret(), 'consumer_key' => "O9lrX7A0iVOifwFhrtrfY40PF", 'consumer_secret' => "LTnannEhUBCpKd84aZjRtsCmXBIZN6JnYUscp9FCYNU3n6m8Zc"); $url = 'https://api.twitter.com/1.1/search/tweets.json'; $requestMethod = 'GET'; $firstPostfield = 'q' . "=" . $query->getText() . "&" . 'geocode' . "=" . $query->getLat() . "," . $query->getLng() . "," . $query->getRadius() . "km" . "&" . 'count' . "=" . '100' . "&" . 'result_type' . "=" . 'recent' . "&" . 'include_entities' . "=" . 'true'; $postfields = $firstPostfield; for ($i = 0; $i < 4; $i++) { $twitter = new TwitterAPIExchange($settings); $titer = $twitter->setGetfield($postfields)->buildOauth($url, $requestMethod)->performRequest(); $tilter = json_decode($titer, true); $max_id = "99999999999999999999"; $statusi = $tilter["statuses"]; foreach ($statusi as $status) { $tweet = new Tweet(); $tweet->setText($status["text"]); $tweet->setLat($status["coordinates"]["coordinates"][1]); if ($tweet->getLat() == null) { $tweet->setLat($query->getLat() + rand(1, 100) / 10000); } $tweet->setLng($status["coordinates"]["coordinates"][0]); if ($tweet->getLng() == null) { $tweet->setLng($query->getLng() + rand(1, 100) / 10000); } if ($status["user"]["name"] === null) { $tweet->setAuthor("Unknown user"); } else { $tweet->setAuthor($status["user"]["name"]); } $tweet->setFavoriteCount($status["favorite_count"]); $tweet->setRetweetCount($status["retweet_count"]); $tweet->setTwitterId($status["id_str"]); $tweet->setQuery($query); $query->addTweet($tweet); $max_id = min($max_id, $status["id_str"]); } if (count($statusi) < 100) { break; } $postfields = $firstPostfield . "&max_id=" . $max_id; } $this->semantic($query); return; }