本文整理汇总了PHP中Flight::guzzle方法的典型用法代码示例。如果您正苦于以下问题:PHP Flight::guzzle方法的具体用法?PHP Flight::guzzle怎么用?PHP Flight::guzzle使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Flight
的用法示例。
在下文中一共展示了Flight::guzzle方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: import
public static function import()
{
$client = PredictionIOClient::factory(array("appkey" => "YOUR_PREDICTIONIO_APP_KEY"));
$index = 0;
for ($x = 3; $x <= 100; $x++) {
$movies_url = 'https://api.themoviedb.org/3/movie/popular?api_key=YOUR_TMDB_API_KEY&page=' . $x;
$movies_response = Flight::guzzle()->get($movies_url);
$movies_body = $movies_response->getBody();
$movies_result = json_decode($movies_body, true);
$movies = $movies_result['results'];
if (!empty($movies)) {
foreach ($movies as $row) {
$id = $row['id'];
$title = $row['title'];
$poster_path = '';
if (!empty($row['poster_path'])) {
$poster_path = $row['poster_path'];
}
$moviedetails_url = 'https://api.themoviedb.org/3/movie/' . $id . '?api_key=YOUR_TMDB_API_KEY';
$moviedetails_response = Flight::guzzle()->get($moviedetails_url);
$movie_details_body = $moviedetails_response->getBody();
$movie = json_decode($movie_details_body, true);
$overview = $movie['overview'];
$release_date = $movie['release_date'];
$command = $client->getCommand('create_item', array('pio_iid' => $index, 'pio_itypes' => 1));
$command->set('tmdb_id', $id);
$command->set('title', $title);
$command->set('poster_path', $poster_path);
$command->set('overview', $overview);
$command->set('release_date', $release_date);
$client_response = $client->execute($command);
print_r($client_response);
echo "<br><br>";
$index++;
}
}
}
}
示例2: import
public static function import()
{
//$client = PredictionIOClient::factory(array("appkey" => "YOUR_PREDICTIONIO_APP_KEY"));
//$accessKey = 'PZATchzAcnbZTzP12WgA1e4sZQGcQLtDJ1CKUlrOVHs7s7zocXbOb1XQAlZnlkSu';
//$client = new EventClient($accessKey, 'http://localhost:7070');
$client = Flight::prediction_client();
$index = 0;
for ($x = 1; $x <= 1; $x++) {
$movies_url = 'https://api.themoviedb.org/3/movie/popular?api_key=b119b6067ef52d84c667d86bd6bab5c3&page=' . $x;
$movies_response = Flight::guzzle()->get($movies_url);
$movies_body = $movies_response->getBody();
$movies_result = json_decode($movies_body, true);
$movies = $movies_result['results'];
if (!empty($movies)) {
foreach ($movies as $row) {
$id = $row['id'];
$title = $row['title'];
$poster_path = '';
if (!empty($row['poster_path'])) {
$poster_path = $row['poster_path'];
}
$moviedetails_url = 'https://api.themoviedb.org/3/movie/' . $id . '?api_key=b119b6067ef52d84c667d86bd6bab5c3';
$moviedetails_response = Flight::guzzle()->get($moviedetails_url);
$movie_details_body = $moviedetails_response->getBody();
$movie = json_decode($movie_details_body, true);
$overview = $movie['overview'];
$release_date = $movie['release_date'];
$client_response = $client->setItem($index, array('itypes' => 1, 'tmdb_id' => $id, 'title' => $title, 'poster_path' => $poster_path, 'overview' => $overview, 'release_date' => $release_date));
echo "<pre>";
print_r($client_response);
echo "</pre>";
echo "<br><br>";
$index++;
}
}
}
}