redcomercio / latch-sdk-php
dev-main
2024-07-22 22:26 UTC
Requires
- php: >=5.3.0
This package is not auto-updated.
Last update: 2024-10-01 21:28:18 UTC
README
LATCH PHP SDK
先决条件
PHP 5.3 或更高版本。
阅读API文档 (https://latch.elevenpaths.com/www/developers/doc_api).
要获取“应用程序ID”和“密钥”(在任何应用程序中集成Latch的基本值),需要在Latch网站上注册开发者账户:https://latch.elevenpaths.com。在上侧右侧,点击“开发者区域”。
在PHP中使用SDK
使用composer要求"latch" SDK
composer require elevenpaths/latch-sdk-php
使用之前获取的“应用程序ID”和“密钥”创建一个Latch对象。
$api = new Latch(APP_ID, APP_SECRET);
可选设置
$api->setProxy(YOUR_PROXY);
调用Latch服务器。配对将返回一个账户ID,您应该为未来的API调用存储它。
$pairResponse = $api->pair("PAIRING_CODE_HERE"); $statusResponse = $api->status(ACCOUNT_ID_HERE); $unpairResponse = $api->unpair(ACCOUNT_ID_HERE);
每次API调用后,获取Latch响应数据和错误并处理它们。
$pairResponse->getData(); $pairResponse->getError();