easyatworkas/sunshineconversations
Composer 安装命令:
composer require easyatworkas/sunshineconversations
包简介
PHP client lib for Sunshine Conversations.
README 文档
README
Install it with composer:
composer require easyatworkas/sunshineconversations
Usage
Authentication
// Create a client. $client = new SmoochApiClient(); $client->setBaseUri('https://easyatwork.zendesk.com/sc/v2'); $client->authenticate('your api key', 'your api secret'); // Create an "app". $app = new SmoochApp($client, 'your app id');
Basics
// Find an existing user. $user = $app->getUser(3)->getData(); // List their conversations. $conversations = $app->listConversations($user['id'])->getData(); // Unless multi conversation mode is enabled, each user will only ever have one conversation. $activeConversation = reset($conversations); $app->createMessageAsBusiness($activeConversation['id'], 'Hello! How can I help you today?');
Pagination
When you have an instance of SmoochApiPaginatedResponse you can invoke hasMore() to see if there are more pages available, then use nextPage() to generate the request parameters required to fetch the next page. Simply pass these parameters back to the relevant request method.
$messages = []; $pageParams = []; do { $response = $app->listMessages($conversation['id'], $pageParams); $messages = array_merge($messages, $response->getData()); } while ($response->hasMore() && $pageParams = $response->nextPage()); foreach ($messages as $message) { echo $message['author']['displayName'] ?? 'Bot', ': ', $message['content']['text'], PHP_EOL; }
统计信息
- 总下载量: 5.93k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 1
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: Unknown
- 更新时间: 2024-11-14