/** * @param $url * @param null $limit * @param int $current */ private function crawl($url, $limit = null, &$current = 0) { echo "call crawl\n"; echo $current . "\n"; echo $limit . "\n"; if (isset($limit) && $limit < $current) { echo "limit is over\n"; echo "save next:{$url}\n"; FileHelper::writeText(Url::to(static::INSTAGRAM_NEXT_URL), $url, true); return 1; } $data = Instagram::httpGet($url); Instagram::savePosts($data); if (!isset($data->pagination) || !isset($data->pagination->next_url)) { echo "end page\n"; return 0; } return $this->crawl($data->pagination->next_url, $limit, ++$current); }
public function actionIndex() { $location = new Location(); $location->attributes = Yii::$app->request->get(); $this->renderJsonpForJquery(Instagram::getPlaces($location)); }
/** * Finds the Instagram model based on its primary key value. * If the model is not found, a 404 HTTP exception will be thrown. * @param integer $id * @return Instagram the loaded model * @throws NotFoundHttpException if the model cannot be found */ protected function findModel($id) { if (($model = Instagram::findOne($id)) !== null) { return $model; } else { throw new NotFoundHttpException('The requested page does not exist.'); } }