承接 easyatworkas/sunshineconversations 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

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

GitHub 信息

  • Stars: 0
  • Watchers: 2
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: Unknown
  • 更新时间: 2024-11-14