simondavies / veezi-api-wrapper
为 Veezi API 简单的 PHP 网站包装器。
Requires
- php: >=5.4.0
- guzzlehttp/guzzle: ^6.1
- nesbot/carbon: ^1.20
This package is not auto-updated.
Last update: 2024-09-28 17:49:23 UTC
README
这是一个基本的 PHP 包装器,用于Veezi API。
这仍然处于开发中,可能会发生变化
在需要查看 Veezi API 以使网站能够显示其相关电影数据,而不重复工作等时,我需要对当前返回的数据进行一些操作,以便在网站上使用,因此找不到任何可用于 Veezi API 的当前 PHP 代码,认为构建这个并将其提供给 Veezi 和其他人也是一个不错的选择。
官方文档
可以在 Veezi API 找到官方文档
代码示例
在存储库中包含一个示例文件夹,在这里您可以找到一些各种选项的工作示例。
电影列表
//-- get the autoload page require_once __DIR__ . '../../vendor/autoload.php'; //-- load in a some settings/configuration file. require_once __DIR__ . '/config.php'; use VeeziAPI\VeeziAPIWrapper as VeeziAPI; $Veezi = new VeeziAPI(VEEZI_API_TOKEN); //--get a list of all films $films = $Veezi->films(); //--loop throught the result and list by film title foreach ($films as $film) { echo '<a href="film.php?filmid=' . $film->getId() . '">' . $film->getTitle() . '</a>'; }
选定电影
//-- get the autoload page require_once __DIR__ . '../../vendor/autoload.php'; //-- load in a some settings/configuration file. require_once __DIR__ . '/config.php'; use VeeziAPI\VeeziAPIWrapper as VeeziAPI; $Veezi = new VeeziAPI(VEEZI_API_TOKEN); //--get a selected film $film = $Veezi->selectedFilm($film_id); //-- film title $film_title = $film->getTitle(); //-- film synopsis $film_synopsis = $film->getSynopsis(); //--film people Actor, Director, Producer $film_people = $film->getPeople();
还有其他可用于电影实例的选项,下面是一些。
$film->getGenre()$film->getFormat()$film->getLanguage()$film->getDatesAndTimes()$film->getRoles()
还有一些以数组和其他对象返回,例如 $film->getStartDate(),返回的是一个 Carbon 实例,因此可以使用 Carbon 提供的任何方法进行转换
//-- set date as a readable date $film->getStartDate()->format('l jS \\of F Y');
选定电影海报
目前无法访问实际的海报。因为海报目前存储在服务器的受保护区域,要通過 URL 获取访问权限,您需要登录到 Veezi 系统。
因此,将 URL 添加到海报将无法实现。Veezi 正在考虑切换,以便它们也可以被引用。在此期间,为了显示海报,您需要创建自己的版本/方法。
如果您需要任何想法或解决方案,请随时联系我,了解如何解决这个问题。
电影角色
对人物进行排序并准备角色列表。(演员/导演/制片人)
//-- return a list of roles and the people for each role $roles = $film->getRoles(); <div class="row"> <div class="col-md-4"> <h4>Actors</h4> <?php echo '<ul class="list-unstyled">'; foreach ($roles['actors'] as $actors) { echo '<li>' . $actors . '</li>';} echo '</ul>'; ?> </div> <div class="col-md-4"> <h4>Directors</h4> <?php echo '<ul class="list-unstyled">'; foreach ($roles['directors'] as $directors) { echo '<li>' . $directors . '</li>';} echo '</ul>'; ?> </div> <div class="col-md-4"> <h4>Producers</h4> <?php echo '<ul class="list-unstyled">'; foreach ($roles['producers'] as $producers) { echo '<li>' . $producers . '</li>';} echo '</ul>'; ?> </div> </div> </div>
输出结果可能如下所示
电影日期/时间 & 门票链接
列出选定电影的日期和时间,在时间上添加预订链接。
您还可以获取选定电影的日期和时间列表,以显示为可点击的链接以预订门票。
//-- Get the films dates and times $film_start_dates = $film->getDatesAndTimes(); //-- Out put the Dates and times foreach ($film_start_dates as $date => $times) { echo '<h5>' . $date . '</h5>'; echo '<div class="btn-group" role="group" aria-label="">'; foreach ($times as $time) { echo '<a class="btn btn-info" href="' . $time['link'] . '?siteToken=' . VEEZI_SITE_TOKEN . '" target="_blank">' . $time['time'] . '</a>'; } echo '</div>'; }
要求
- PHP >= 5.4.0
- Veezi 活跃账户
- Veezi API 令牌
- guzzlehttp/guzzle
- nesbot/Carbon
安装
建议通过 Composer 安装此存储库
通过 Composer 安装
如果您将此作为初始项目使用,则可以通过以下方式安装:
composer create-project simondavies/veezi-api-wrapper
否则包括在当前项目运行中
composer.phar require simondavies/veezi-api-wrapper
通过Github/不使用Composer安装
通过SSH
git clone git@github.com:simondavies/Veezi-API-Wrapper.git target-directory
通过HTTPS
git clone https://github.com/simondavies/Veezi-API-Wrapper.git target-directory
设置
一旦项目已下载,我们需要继续初始设置。
cd target-directory
composer update
添加配置文件。
cd App
cp config.example.php config.php
使用您的Veezi API和网站令牌更新以下详细信息。
define('VEEZI_API_TOKEN', '?????????');
define('VEEZI_SITE_TOKEN', '??????????');
完成这些后,您可以通过浏览器访问Examples文件夹来检查一切是否正常。
如果不是从Composer安装,请查看其他所需存储库的安装指南。
待办事项
由于这正在进行中,以下列出了待办事项
- 构建电影类
- 构建电影院类(s)
- 构建放映室类(s)
- 添加示例
- 为电影创建预订链接
- 为每部电影创建电影日期
- 更详细的read me文件或wiki
许可
Veezi-API-Wrapper是开源软件,许可协议为MIT许可证

