smartoysters/saferme-api

PHP版本的SaferMe API客户端

dev-master 2023-10-31 06:52 UTC

This package is auto-updated.

Last update: 2024-08-30 01:49:40 UTC


README

Build Status

本包为PHP提供了一个完整的、不依赖于框架的SaferMe API客户端库。

欢迎通过邮箱 james.rickard@oceanfarmr.com 或在 @frodosghost 上联系我。

文档

查看SaferMe 文档

安装

您可以通过composer require命令安装此包

composer require smartoysters/saferme-api

或者简单地在您的composer.json依赖项中添加它并运行composer update

"require": {
    "smartoysters/saferme-api": "^1.0"
}

使用方法

请参考认证文档页面提供的详细信息。

$installationId应请求为针对此客户端、此应用程序和此API密钥的唯一值。我们在random.org上生成了此值,并从中选择一个生成的密钥,然后在集成中使用它。$teamId用于从SaferMe中的组织提取信息。

$email = 'xxxxxxxxxxxxxxxxxxxxxxxxxxx';
$password = 'xxxxxxxxxxxxxxxxxxxxxxxxxxx';
$appId = 'com.thundermaps.main';
$appBundleId = 'com.thundermaps.saferme';
$teamId = 1234;
$installationId = '';

$saferme = new SaferMe::OAuth([
    'email' => $email,
    'password' => $password,
    'appId' => $appId,
    'appBundleId' => $appBundleId,
    'installationId' => $installationId
]);

团队

如果您使用此客户端访问多个团队,您可以在构造函数中配置一个团队,并在调用端点之前使用->team()函数引用另一个团队。

// As above
$saferme = new SaferMe::OAuth([
    'email' => $email,
    'password' => $password,
    'appId' => $appId,
    'teamId' => $teamId,
    'appBundleId' => $appBundleId,
    'installationId' => $installationId
]);

$teamId = 4321;

$saferme->team($teamId)->channels()->list();

Guzzle客户端选项

构造函数中的选项值允许为Guzzle客户端配置任何数量的默认请求选项。

$options = [
    'timeout'         => 0,
    'allow_redirects' => false,
    'proxy'           => '192.168.16.1:10'
];

$saferme = new SaferMe::OAuth([
    'email' => $email,
    'password' => $password,
    'appId' => $appId,
    'installationId' => $installationId,
    'options' => $options
]);

灵感

本包的灵感来自Devio/Pipedrive - 它是API交互的优美代码格式。查看他的twitter:@IsraelOrtuno