orderchamp/orderchamp-api-php

PHP版的Orderchamp API客户端

1.1.0 2021-07-15 16:07 UTC

This package is auto-updated.

Last update: 2024-09-29 05:02:42 UTC


README

这是一个orderchamp.com API的PHP客户端。更多API文档可以在以下链接找到:https://developers.orderchamp.com

安装

安装composer包

composer require Orderchamp/orderchamp-api-php

使用

以下步骤仅在您构建需要OAuth的公共应用时必要。如果您构建的是私有连接,您将从Orderchamp获得一个访问令牌,可以直接使用。

use Orderchamp\Api\OrderchampApiClient;

$client = new OrderchampApiClient([
    'client_id'     => 'your_client_id',
    'client_secret' => 'your_client_secret',
]);

// Redirect the user to this url for authorization
$authorizationUrl = $client->authorizationUrl($this->config['scopes'], 'redirect_url_goes_here');

// We redirect the user back to your redirect url
// Call the method with the $_GET parameters and we'll fetch you a token
$token = $client->requestToken($request->all());

// Persist this token and use it moving forward
$client->setAccessToken($token);
$response = $client->graphql('{ account { id name } }');

dd($response);