public function actionLoad($geocode) { $token = new OAuthToken(['token' => Yii::$app->params['twitterAccessToken'], 'tokenSecret' => Yii::$app->params['twitterAccessTokenSecret']]); $twitter = new Twitter(['accessToken' => $token, 'consumerKey' => Yii::$app->params['twitterApiKey'], 'consumerSecret' => Yii::$app->params['twitterApiSecret']]); $list = $twitter->api('search/tweets.json', 'GET', ['geocode' => $geocode]); $response = []; foreach ($list['statuses'] as $t) { $tweet = Tweet::loadFromJSON($t); if ($tweet) { $response[] = $tweet->getAttributes(); } } return json_encode($response); }
/** * @param int $limit * * @return array * @throws \yii\base\Exception */ public function getPosts($limit = 200) { return $this->parseGetPosts($this->service->api('statuses/user_timeline.json'), null, ['id', 'text'], ['service_id_author' => 'user.id', 'service_id_post' => 'id', 'time_created' => 'created_at', 'content' => 'text']); }