api-allocine / api-allocine-helper
使用Allocine API的简单方法
Requires
- php: >=5.3.0
This package is not auto-updated.
Last update: 2024-09-28 15:03:15 UTC
README
Allocine API Helper API 允许更简单地使用Allocine API。类 AlloHelper 允许查找有关电影、明星、文章、时间和评论的信息。可以通过类 AlloData(可选)来处理接收到的数据。类 AlloImage 允许轻松处理存储在Allocine上的海报和图片的大小。
安装
将文件 api-allocine-helper.php
移动到所需的目录。只需在代码中使用 require_once "./api-allocine-helper.php";
即可使用 API。
使用
使用非常简单,尽管强烈建议了解面向对象的编程和 try{} catch(){}
块。以下是一个获取电影信息的示例
首先,包含文件并创建一个 AlloHelper
对象
<?php
// Inclure le script
require_once "./api-allocine-helper.php";
// Créer l'objet
$helper = new AlloHelper;
为了更清晰,我们事先定义参数:电影的代码和要获取的信息数量。
$code = 27061;
$profile = 'small';
然后,建议在 try{} catch(){}
块中执行请求以处理错误。
try
{
// Envoi de la requête
$movie = $helper->movie( $code, $profile );
// Afficher le titre
echo "Titre du film: ", $movie->title, PHP_EOL;
// Afficher toutes les données
print_r($movie->getArray());
}
catch( ErrorException $error )
{
// En cas d'erreur
echo "Erreur n°", $error->getCode(), ": ", $error->getMessage(), PHP_EOL;
}
?>
英文
API Allociné Helper 是使用 AlloCiné API 的支持。使用类 AlloHelper 查找有关电影、人物、电视剧等的大量信息。可以通过类 AlloData(可选)来处理接收到的数据。此外,您还可以通过更改 URL 使用类 AlloImage 简单地修改 Allocine 服务器上的海报和照片。
安装
这是一个脚本,您将其放入您喜欢的目录,并在代码中使用 require_once "./api-allocine-helper.php";
。
使用
使用非常简单,但是强烈建议了解 OOP 和 try{} catch(){}
块。
首先,创建一个 AlloHelper
对象
<?php
// Include the script
require_once "./api-allocine-helper.php";
// Creat the object
$helper = new AlloHelper;
为了更清晰,我们应该事先定义参数:电影的代码和要获取的信息数量。
$code = 27061;
$profile = 'small';
接下来,建议在 try{} catch(){}
块中执行请求以处理错误。
try
{
// Request sending
$movie = $helper->movie( $code, $profile );
// Print the title
echo "Title: ", $movie->title, PHP_EOL;
// Print all data
print_r($movie->getArray());
}
catch( ErrorException $error )
{
// Error
echo "Error ", $error->getCode(), ": ", $error->getMessage(), PHP_EOL;
}
?>