rkcreative / laravel-mesibo-api
Laravel 的 Mesibo API 集成
Requires
- php: ^7.2
- ext-json: *
- guzzlehttp/guzzle: ^5.0|^6.0|^7.2
- illuminate/support: ^5.0|^6.0|^7.0|^8.0
Requires (Dev)
- orchestra/testbench: ^4.0|^5.0|^6.0
This package is auto-updated.
Last update: 2024-09-16 23:05:42 UTC
README
将 Mesibo 后端 API 集成到您的应用程序中的 Laravel 包。
依赖项
- PHP: ^7.2
- guzzlehttp/guzzle: 5.* | 6.* | 7.\
- illuminate/support: 5.* | 6.* | 7.* | 8.*
要求
您需要在 Mesibo 上创建一个账户,创建一个应用程序并获取应用程序令牌。您需要在配置文件中定义应用程序令牌和 API URL。API URL 将是默认的 Mesibo 后端 API URL(《https://api.mesibo.com/api.php》)或您自己的托管 URL。
安装
您可以通过 Composer 安装此包
$ composer require rkcreative/laravel-mesibo-api
在 Laravel 5.5 或更高版本中,服务提供程序将自动注册。在框架的较旧版本中,只需在 config/app.php
文件中添加服务提供程序即可
'providers' => [
...
/*
* Package Service Providers...
*/
RKCreative\LaravelMesiboApi\LaravelMesiboApiServiceProvider::class,
...
],
'aliases' => [
...
'MesiboApi' => RKCreative\LaravelMesiboApi\LaravelMesiboApiFacade::class,
...
],
您可以使用以下命令发布配置文件
$ php artisan vendor:publish --provider="RKCreative\LaravelMesiboApi\LaravelMesiboApiServiceProvider" --tag=config
发布后,配置文件 config/mesibo-api .php
包含以下内容
<?php
return [
/*
|--------------------------------------------------------------------------
| Mesibo App Token
|--------------------------------------------------------------------------
|
| You can generate an app token for your app from the Mesibo dashboard
| and enter it here
|
*/
'app_token' => env('MESIBO_APP_TOKEN', ''),
/*
|--------------------------------------------------------------------------
| Mesibo API Url
|--------------------------------------------------------------------------
|
| Add the Mesibo API url here
|
*/
'api_url' => env('MESIBO_API_URL', 'https://api.mesibo.com/api.php'),
/*
|--------------------------------------------------------------------------
| App ID
|--------------------------------------------------------------------------
|
| Each of your apps (web/ios/android) will have a unique app id. For
| this app, you can just use the app name define in your app config or
| anything that will help you identify where your users are interacting
| from. (ie, com.yourdomain.yourapp)
|
*/
'app_id' => config('app.name', 'MyApp'),
];
用法
以下每个操作都需要返回结果所需的必要和可选参数。 您可以阅读更多有关 Mesibo API 选项 的信息。
外观
创建用户
Mesibo::addUser($identifier, $name = null, $parameters = [])
接受
- identifier
(string):required
用户的一个唯一标识符。 - name
(string):optional
一个标签或名称,例如用户名。 - parameters
(array):optional
由 Mesibo 提供的可选参数数组。
在 成功 时返回
- user
(object)
一个用户对象- uid
(string);
一个唯一的用户 ID。 - token
(string)
一个唯一的令牌。
- uid
在 失败 时返回
- false
(boolean)
示例
$user = \Mesibo::addUser('user1@mail.com', 'User1');
$uid = $user->uid;
$token = $user->token;
编辑用户
Mesibo::editUser($uid, $parameters = [])
接受
- uid
(string):required
添加用户时返回的用户 ID。 - parameters
(array):optional
由 Mesibo 提供的可选参数数组。
在 成功 时返回
- true
(boolean)
在 失败 时返回
- false
(boolean)
示例
\Mesibo::editUser('12345', ['active' => '0']);
删除用户
Mesibo::deleteUser($uid)
接受
- uid
(string):required
添加用户时返回的用户 ID。
在 成功 时返回
- true
(boolean)
在 失败 时返回
- false
(boolean)
示例
\Mesibo::deleteUser('12345');
删除用户令牌
Mesibo::deleteToken($uid)
接受
- uid
(string):required
添加用户时返回的用户 ID。
在 成功 时返回
- true
(boolean)
在 失败 时返回
- false
(boolean)
示例
\Mesibo::deleteToken('12345');
创建组
Mesibo::addGroup($name = null, $parameters = [])
接受
- name
(string):optional
组的可选名称。 - parameters
(array):optional
由 Mesibo 提供的可选参数数组。
在 成功 时返回
- gid
(string)
一个唯一的组 ID。
在 失败 时返回
false
示例
$gid = \Mesibo::addGroup(null, ['flag' => '0']);
编辑组
Mesibo::editGroup($gid, $parameters[] = null)
接受
- gid
(string):required
添加组时返回的组 ID。 - parameters
(array):optional
由 Mesibo 提供的可选参数数组。
在 成功 时返回
- true
(boolean)
在 失败 时返回
- false
(boolean)
示例
\Mesibo::editGroup('12345', ['active' => '0']);
添加或删除组成员
Mesibo::editGroupMembers($gid, $members, $delete = false, $parameters = [])
接受
- gid
(string):required
添加组时返回的组 ID。 - members
(string):optional
使用以创建用户的标识符分隔的成员列表。 - delete
(boolean):optional
如果设置为 true,则从组中删除成员列表。默认为 false。 - parameters
(array):optional
由 Mesibo 提供的可选参数数组。
在 成功 时返回
- true
(boolean)
在 失败 时返回
- false
(boolean)
示例
\Mesibo::editGroupMembers('12345', 'user@mail.com,user2@mail.com,user3@mail.com', false, ['cs' => '0']);
删除组
Mesibo::deleteGroup($gid)
接受
- gid
(string):required
添加组时返回的组 ID。
在 成功 时返回
- true
(boolean)
在 失败 时返回
- false
(boolean)
示例
\Mesibo::deleteGroup('12345');
测试
$ composer test
贡献
添加代码
此库当前支持的行动不完全。随着时间的推移,将添加更多操作。如果您想为此库做出贡献,请创建一个拉取请求。
安全漏洞
如果您发现任何安全相关的问题,请使用问题跟踪器。所有安全漏洞都将得到迅速解决。
许可证
Laravel Mesibo API 包是开源软件,许可协议为 MIT 许可证。