vision-rhythm/douyin-open-php

There is no license information available for the latest version (v1.0.2) of this package.

VisionRhythm php Library

v1.0.2 2022-01-05 14:58 UTC

This package is auto-updated.

Last update: 2024-04-05 20:10:40 UTC


README

You can sign up for a MasJPay account at https://www.visionrhythm.com/.

Requirements

PHP 5.6.0 and later.

Composer

You can install the bindings via Composer. Run the following command:

composer require vision-rhythm/douyin-open-php

To use the bindings, use Composer's autoload:

require_once('vendor/autoload.php');

Manual Installation

If you do not wish to use Composer, you can download the latest release. Then, to use the bindings, include the init.php file.

require_once('/path/to/douyin-open-php/init.php');

Dependencies

The bindings require the following extensions in order to work properly:

  • curl, although you can use your own non-cURL client if you prefer
  • json
  • mbstring (Multibyte String)

If you use Composer, these dependencies should be handled automatically. If you install manually, you'll want to make sure that these extensions are available.

Getting Started

Simple usage looks like:

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();
    }
}

Development

Get [Composer][composer]. For example, on Mac OS:

brew install composer

Install dependencies:

composer install

Install dependencies as mentioned above (which will resolve PHPUnit), then you can run the test suite:

./vendor/bin/phpunit

Or to run an individual test file:

./vendor/bin/phpunit tests/UtilTest.php

The method should be called once, before any request is sent to the API. The second and third parameters are optional.