snappy/php-sdk

BeSnappy.com 的 PHP SDK

v1.0.1 2014-07-21 20:45 UTC

This package is not auto-updated.

Last update: 2024-09-09 11:32:37 UTC


README

安装

应通过 Composer 安装 SDK。只需将 snappy/php-sdk 依赖项添加到您的 composer.json 文件中。

用法

首先,创建一个新的身份验证提供者

$auth = new SnappySdk\UserPassAuthentication('user', 'pass');

然后,创建 SDK 客户端实例

$client = new SnappySdk\Client($auth);

现在您可以开始从 Snappy 获取信息了!

$accounts = $client->getAccounts();

发送消息

要向您的 Snappy 账户发送消息,创建一个新的 Message 实例,并在客户端使用 sendMessage 方法

$message = new SnappySdk\Message;

$message->mailboxId = 3;
$message->setFrom('foo@bar.com', 'John Smith');
$message->subject = 'Hello World';
$message->message = 'This is my message!';

$nonce = $client->sendMessage($message);

要发送外发消息,必须指定 staffId 以及收件人地址

$message = new SnappySdk\Message;

$message->mailboxId = 3;
$message->staffId = 3;
$message->addTo('foo@bar.com', 'John Smith');
$message->subject = 'Hello World';
$message->message = 'This is my message!';

$nonce = $client->sendMessage($message);

如果您要将消息附加到现有的线程,请将票据 "nonce" 添加到消息中

$message->ticketId = $nonce;

可用方法

以下是可用的 SDK 客户端方法。它们都与 Snappy API 交互。

  • getAccounts
  • search($query, $page = 1)
  • getMailboxes($accountId)
  • getDocuments($accountId)
  • getStaff($accountId)
  • getContact($accountId, $idOrEmailAddress)
  • getWaitingTickets($mailboxId)
  • getTicketDetails($ticketId)
  • getTicketNotes($ticketId)
  • updateTicketTags($ticketId, $tags)
  • sendMessage($message)
  • getWallPost($accountId, $after = 0)
  • postToWall($accountId, $content, $type = 'post', $tags = array(), $ticket = null, $note = null)
  • deleteWallPost($accountId, $postId)
  • commentOnWallPost($accountId, $postId, $comment)
  • deleteWallComment($accountId, $postId, $commentId)
  • likeWallPost($accountId, $postId)
  • unlikeWallPost($accountId, $postId)
  • getFaqs($accountId)
  • searchFaqs($accountId, $query, $page = 1)
  • createFaq($accountId, $title, $url = 'faq')
  • updateFaq($accountId, $faqId, $title, $url = 'faq')
  • deleteFaq($accountId, $faqId)
  • getFaqTopics($accountId, $faqId)
  • createFaqTopic($accountId, $faqId, $topic, $order = 0)
  • updateFaqTopic($accountId, $faqId, $topic, $order = 0)
  • deleteFaqTopic($accountId, $faqId, $topicId)
  • getTopicQuestions($accountId, $faqId, $topicId)
  • createTopicQuestion($accountId, $faqId, $topicId, $question, $answer)
  • updateTopicQuestion($accountId, $faqId, $topicId, $questionId, $question, $answer)
  • deleteTopicQuestion($accountId, $faqId, $topicId, $questionId)