/** * @param $hashtag * @return Post[] * @throws \Exception */ public function getByHash($hashtag) { $this->client->setGetfield('?q=#' . $hashtag); $this->client->buildOauth(self::URL, self::METHOD); $response = json_decode($this->client->performRequest(true, array(CURLOPT_SSL_VERIFYPEER => false))); return $this->formatter->format($response); }
/** * TWITTER hämta tweets * http://stackoverflow.com/questions/12916539/simplest-php-example-for-retrieving-user-timeline-with-twitter-api-version-1-1 * https://github.com/J7mbo/twitter-api-php */ public function getTweets($numberOfTweets = 0) { $ret = array(); $url = 'https://api.twitter.com/1.1/statuses/user_timeline.json'; $getfield = '?screen_name=al223ec'; $requestMethod = 'GET'; $twitter = new TwitterApiExchange($this->twitterSettings); $decode = json_decode($twitter->setGetfield($getfield)->buildOauth($url, $requestMethod)->performRequest(), true); if ($decode) { $index = 1; foreach ($decode as $key => $value) { if ($value['user'] && $value['text']) { $ret[] = new Tweet($value['user']['name'], $value['text'], $value['user']['screen_name']); } $index += 1; if ($numberOfTweets !== 0 && $index > $numberOfTweets) { break; } } } return $ret; }