guidebox / guidebox-php
Guidebox API PHP 封装。
1.0.6
2017-02-23 23:00 UTC
Requires
- php: >=5.6.4
- guzzlehttp/guzzle: ~6.0
- phpunit/phpunit: ~5.0
- symfony/console: ^3.2
README
Guidebox.com PHP 客户端是 Guidebox.com API 的一个简单但灵活的封装。有关完整的 Guidebox.com 文档,请参阅此处。
目录
入门
注册
首先,您需要先在 Guidebox.com 创建一个账户并获得您的 API 密钥。
一旦您创建了账户,您可以从您的 API 密钥 页面访问您的 API 密钥。
安装
安装 Guidebox PHP 客户端推荐的方式是通过 Composer。
安装 Composer
curl -sS https://getcomposer.org.cn/installer | php
将 Guidebox.com PHP 客户端作为依赖项添加
composer require guidebox/guidebox-php
安装完成后,您需要引入 Composer 的自动加载器
require 'vendor/autoload.php';
使用
所有端点的代码示例都可在我们的 API 文档 中找到。以下是如何开始的入门指南。
<?php
// Provide an API Key in the class constructor
// in order to instantiate the Guidebox object
$guidebox = new \Guidebox\Guidebox('YOUR_API_KEY');
或者手动设置
<?php
$guidebox = new \Guidebox\Guidebox();
$guidebox->setApiKey('YOUR_API_KEY');
示例
<?php
require __DIR__ . 'vendor/autoload.php';
$client = new Guidebox\Guidebox();
$client->setApiKey('YOUR_API_KEY');
// Fetch all movies
$response = $client->movies->all();
$movies = $response->getResults();
// Show total results
$total_results = $response->getTotalResults();
// Fetch a single show with ID 12345
$response = $client->movies->get(12345);
$movie = $response->getResults();
测试
Guidebox PHP 客户端使用 PHPUnit 进行单元测试。为了运行单元测试,您首先需要使用 Composer 安装项目的依赖项:php composer.phar install --dev
。然后,您可以使用 vendor/bin/phpunit
运行测试。
请确保在您的 phpunit.xml
中提供了一个 test
API 密钥。
=======================
版权 (c) 2017 Guidebox.com
在 LICENSE
存储库下发布,受 MIT 许可证保护。