private function getTweets($data)
 {
     //Creating data to call Twitter API
     $consumer_key = $this->container->getParameter('twitter_app_id');
     $consumer_secret = $this->container->getParameter('twitter_secret');
     $searchUrlParams = "";
     $curl = new Curl();
     $curl->setVerifyPeer(false);
     //Getting the search and all the options
     $searchParams = $data['searchParams'];
     $tabSearch = explode(" ", $searchParams);
     foreach ($tabSearch as $elem) {
         $searchUrlParams .= $elem;
     }
     $lang = $data['lang'];
     $resultType = $data['resultType'];
     //Getting tweets
     $client = new Browser($curl);
     $consumer = new Consumer($client, $consumer_key, $consumer_secret);
     //$consumer->setConverter('/1.1/search/tweets.json', new TwitterSearchConverter());
     $query = $consumer->prepare('/1.1/search/tweets.json', 'GET', array('q' => $searchUrlParams, 'lang' => $lang, 'resultType' => $resultType));
     $results = $consumer->execute($query);
     return $resultsDecode = json_decode(json_encode($results->toArray()));
 }
Ejemplo n.º 2
0
 public function testGetConverter()
 {
     $client = $this->getClient();
     $consumer = new Consumer($client, 'consumer_key', 'consumer_secret');
     $this->assertTrue($consumer->getConverter('/me') instanceof DefaultConverter);
     $converter = $this->getMock('Twitter\\ConverterInterface', array('convert'));
     $consumer->setConverter('/me', $converter);
     $this->assertEquals($converter, $consumer->getConverter('/me'));
     $consumer->setConverter('/some/strange/api/method/with/strange/characters/łąóąłąłąóżżźźżąóąłąó', $converter);
     $this->assertEquals($converter, $consumer->getConverter('/some/strange/api/method/with/strange/characters/łąóąłąłąóżżźźżąóąłąó'));
 }