smartsupp / php-partner-client
此包最新版本(1.1)没有可用的许可证信息。
API 客户端允许通过 Smartsupp 合作伙伴 API 进行注册和登录(获取 API 密钥)。
1.1
2019-09-30 15:08 UTC
Requires
- php: >=5.3.2
Requires (Dev)
- phpunit/phpunit: 4.8.*
This package is auto-updated.
Last update: 2024-09-26 09:58:06 UTC
README
Smartsupp 认证 API PHP 客户端
开始使用
- 如果响应中不包含
error
属性,则响应成功。 error
是错误的可读名称,而message
是对错误的用户可读描述。
创建
$api = new Smartsupp\Auth\Api(); $response = $api->create(array( 'email' => 'LOGIN_EMAIL', // required 'password' => 'YOUR_PASSWORD', // optional, min length 6 characters 'name' => 'John Doe', // optional 'lang' => 'en', // optional, lowercase; 2 characters 'partnerKey' => 'PARTNER_API_KEY' // optional )); // print_r($response); // success response array( 'account' => array( 'key' => 'CHAT_KEY', 'lang' => 'en' ), 'user' => array( 'email' => 'LOGIN_EMAIL', 'name' => 'John Doe', 'password' => 'YOUR_PASSWORD' ) ); // print_r($response); // failure response array( 'error' => 'EmailExists', 'message' => 'Email already exists', 'hint' => 'email' );
错误
AuthError
- 无效的 PARTNER_KEY。InvalidParam
- 缺少或无效的参数(例如:邮箱)。EmailExists
- 邮箱已被占用。
登录
$api = new Smartsupp\Auth\Api(); $response = $api->login(array( 'email' => 'LOGIN_EMAIL', 'password' => 'YOUR_PASSWORD' )); // print_r($response); // success response array( 'account' => array( 'key' => 'CHAT_KEY', 'lang' => 'en' ) ); // print_r($response); // failure response array( 'error' => 'InvalidCredential', 'message' => 'Invalid password' );
错误
AuthError
- 无效的 PARTNER_KEY。InvalidParam
- 缺少或无效的参数(例如:无效的邮箱,密码太短)。IdentityNotFound
- 没有此邮箱的账户。InvalidCredential
- 邮箱存在,密码错误。LoginFailure
- 登录有问题。
要求
为了与多个插件库的向后兼容性,库从 PHP 版本 5.3 开始支持。在不久的将来,约束条件可能将更改为 5.6+。
版权
版权所有(c)2016 Smartsupp.com,s.r.o.