/** * @Given a refresh token */ public function aRefreshToken() { //$this->refreshToken = $this->getEnvValueAndThrowIfNotSet("GettyImagesApi_RefreshToken"); $envToGetKeyFrom = "GettyImagesApi_UserName"; $username = $this->getEnvValueAndThrowIfNotSet($envToGetKeyFrom); $envToGetKeyFrom = "GettyImagesApi_UserPassword"; $password = $this->getEnvValueAndThrowIfNotSet($envToGetKeyFrom); $sdk = new GettyImages_Client($this->sharedContext->apiKey, $this->sharedContext->apiSecret, $username, $password, null); $this->accessTokenResponse = $sdk->getAccessToken(); $this->refreshToken = $this->accessTokenResponse['refresh_token']; }
/** * Получаем авто * * @param Request $request * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View */ public function getAuto(Request $request) { Session::put('models', $request->input('model')); $model = Session::get('models'); $mark = Session::get('mark'); $jsonData = file_get_contents("http://api.auto.ria.com/categories/1/marks/{$mark}/models"); $models = json_decode($jsonData, true); $nameAuto = ''; foreach ($models as $mod) { if ($mod['value'] == $model) { if (!empty($nameAuto)) { unset($nameAuto); } $nameAuto = $mod['name']; } } Session::put('nameAuto', $nameAuto); $jsonData = file_get_contents("http://api.auto.ria.com/categories/1/marks"); $typeTrans = json_decode($jsonData, true); //$mark = Session::get('mark'); $name = Session::get('name'); if (Session::has('mark') && Session::has('models')) { $apiKey = "nf87gm4kggpc6xpff4huawx7"; $apiSecret = "qXpdWXq3yzYmHJsDb4yCpUM3wKcBKevPbcfFnPHvVWvuC"; $client = new GettyImages_Client($apiKey, $apiSecret); $response = $client->Search()->Images()->withPhrase($name)->execute(); $data = json_decode($response); //dd($data->images); $imgArr = []; foreach ($data->images as $images) { foreach ($images->display_sizes as $img) { $imgArr[] = $img->uri; } } } return view('index.index', compact('typeTrans', 'data', 'imgArr')); }