vision-rhythm / douyin-open-php
该包最新版本(v1.0.2)没有可用的许可信息。
VisionRhythm php 库
v1.0.2
2022-01-05 14:58 UTC
Requires
- php: >=5.6.0
- ext-bcmath: *
- ext-curl: *
- ext-json: *
- ext-mbstring: *
README
您可以在 https://www.visionrhythm.com/ 上注册 MasJPay 账户。
要求
PHP 5.6.0 及以上。
Composer
您可以通过 Composer 安装绑定。运行以下命令
composer require vision-rhythm/douyin-open-php
要使用绑定,使用 Composer 的 自动加载
require_once('vendor/autoload.php');
手动安装
如果您不想使用 Composer,您可以下载最新的 发布版本。然后,为了使用绑定,包含 init.php
文件。
require_once('/path/to/douyin-open-php/init.php');
依赖项
绑定需要以下扩展才能正常工作
如果您使用 Composer,这些依赖项应该会自动处理。如果您手动安装,请确保这些扩展可用。
入门
简单用法如下
const CLIENT_ID = ''; const CLIENT_SECRET = ''; \Visionrhythm\VisionRhythm::setDebug(true); //调试模式 true /false \Visionrhythm\VisionRhythm::setApiMode('sandbox'); //环境 live 线上,sandbox 沙盒 \Visionrhythm\VisionRhythm::setclientId(CLIENT_ID); // 设置 id \Visionrhythm\VisionRhythm::setclientSecret(CLIENT_SECRET); // secret \VisionRhythm\VisionRhythm::setRedirectUri(''); //回调地址 $open_id = ''; $access_token = ''; try { $userInfo = \VisionRhythm\User::info($open_id, $access_token); echo($userInfo)."\r\n"; $fans = \VisionRhythm\User::fans($open_id, $access_token, 0, 10); echo($fans)."\r\n"; $following = \VisionRhythm\User::following($open_id, $access_token, 0, 10); echo($following)."\r\n"; } catch (\Visionrhythm\Error\Base $e) { if ($e->getHttpStatus() != null) { header('Status: ' . $e->getHttpStatus()); echo $e->getHttpBody(); } else { echo $e->getMessage(); } }
开发
获取 [Composer][composer]。例如,在 Mac OS 上
brew install composer
安装依赖项
composer install
如上所述安装依赖项(这将解决 PHPUnit),然后您可以运行测试套件
./vendor/bin/phpunit
或运行单个测试文件
./vendor/bin/phpunit tests/UtilTest.php
该方法应仅调用一次,在向 API 发送任何请求之前。第二个和第三个参数是可选的。