苏迪普乔杜里/php-zoho-subscriptions

PHP 客户端库,用于使用 Zoho Subscriptions REST API

v0.4.3 2024-06-26 09:46 UTC

README

Latest Stable Version Latest Unstable Version License Total Downloads composer.lock available

Zoho Subscriptions API for PHP 的客户端

use SudiptoChoudhury\Zoho\Subscriptions\Api;

...

$subscriptions = new Api([
                'oauthtoken' => '<<Zoho Subscriptions OAuth Token>>', // https://www.zoho.com/subscriptions/api/v1/#oauth
                'zohoOrgId' => '<<Zoho Organization ID>>',
            ]);


$resultJson = $subscriptions->addCustomer($data); // create a customer

$resultJson = $subscriptions->addSubscription($data); // create a subscription
 
 

身份验证令牌(将很快被弃用),但您仍然可以使用它。

use SudiptoChoudhury\Zoho\Subscriptions\Api;

...

$subscriptions = new Api([
                'authtoken' => '<<Zoho Subscriptions Auth Token>>', // https://accounts.zoho.com/apiauthtoken/nb/create
                'zohoOrgId' => '<<Zoho Organization ID>>',
            ]);


$resultJson = $subscriptions->addCustomer($data); // create a customer

$resultJson = $subscriptions->addSubscription($data); // create a subscription
 
 

安装

需求

  • 任何版本的 PHP 7.0+

使用 Composer 安装

您可以通过将以下行添加到您的 composer.json 文件中的 require 块中来安装库(用最新稳定版本替换 dev-master)

"sudiptochoudhury/php-zoho-subscriptions": "dev-master"

或者运行以下命令

composer require sudiptochoudhury/php-zoho-subscriptions

设置身份验证

获取组织 ID 在开始之前,请阅读 https://www.zoho.com/subscriptions/api/v1/#organization-id 了解您的组织 ID。

设置 OAuth 并使用 OAuth 令牌

遵循 https://www.zoho.com/subscriptions/api/v1/#oauth 中的说明以获取 oathtoken

通过构造函数传递 OAuth 令牌。

use SudiptoChoudhury\Zoho\Subscriptions\Api;


new Api([
    'oauthtoken' => '<<Zoho Subscriptions OAuth Token>>', // https://www.zoho.com/subscriptions/api/v1/#oauth
    'zohoOrgId' => '<<Zoho Organization ID>>',
]);

或者使用 AuthToken

将很快被弃用

https://accounts.zoho.com/apiauthtoken/nb/create 中创建并检索 AuthToken,然后在构造函数中设置 AuthToken 和组织 ID。

use SudiptoChoudhury\Zoho\Subscriptions\Api;


new Api([
    'authtoken' => '<<Zoho Subscriptions Auth Token>>', // https://accounts.zoho.com/apiauthtoken/nb/create
    'zohoOrgId' => '<<Zoho Organization ID>>',
]);

如何使用

接下来,调用下表中给出的所需方法。在某些方法中,您可能需要传递参数。参数应以关联数组的形式传递。所需参数列表可在表的参数列中找到,或者您也可以通过查看原始 Zoho Subscription API 文档来获取更多详细信息。

示例

$resultJson = $subscriptions->getOrganizations(); 

$resultJson = $subscriptions->addCustomer(['display_name'=> 'Sudipto Choudhury', 'email'=> 'mail@sudipto.net']); // create a customer

可用的 API 方法