livechat/api-client-php

使PHP应用程序能够与LiveChat API进行通信。

v1.1.1 2016-01-15 09:01 UTC

This package is not auto-updated.

Last update: 2024-09-12 13:23:11 UTC


README

连接到LiveChat REST API的PHP客户端。

文档

了解更多信息,请访问官方的LiveChat REST API文档

LiveChat API客户端的先前版本。

要求

  • PHP 5.3或更高版本
  • cUrl扩展已启用

通过HTTP基本认证进行API认证。提供您的

  • 登录名
  • API密钥

更多信息: https://developers.livechatinc.com/rest-api/#authentication

安装

Composer

$ composer require livechat/api-client-php "@dev"

或者,在您的composer.json中设置devminimum-stability

    "minimum-stability": "dev"

然后

 $ composer require livechat/api-client-php
 $ composer update

执行测试

此操作需要安装PHPUnit。

 $ phpunit

基本用法

<?php

require_once __DIR__ . '/vendor/autoload.php';

use LiveChat\Api\Client as LiveChat;

$LiveChatAPI = new LiveChat('%login%', '%apiKey%');
$agents = $LiveChatAPI->agents->get();

可用方法

方法返回stdClass(解析后的JSON响应)。

代表

代表REST API文档.

  • $LiveChatAPI->agents->get($login = null)
  • $LiveChatAPI->agents->add(array $vars)
  • $LiveChatAPI->agents->update($login, array $vars)
  • $LiveChatAPI->agents->delete($login)

快速回复

快速回复REST API文档.

  • $LiveChatAPI->cannedResponses->get($group = 0)
  • $LiveChatAPI->cannedResponses->getSingleResponse($id)
  • $LiveChatAPI->cannedResponses->addNewResponse($text, $tags)
  • $LiveChatAPI->cannedResponses->updateResponse($id, $text, $tags)
  • $LiveChatAPI->cannedResponses->deleteResponse($id)

聊天存档

存档REST API文档.

  • $LiveChatAPI->chats->get($params = array())
  • $LiveChatAPI->chats->getSingleChat($chatId)
  • $LiveChatAPI->chats->updateTags($id, array $vars)

目标

目标REST API文档.

  • $LiveChatAPI->goals->markAsSuccessful($goalId)

组REST API文档.

  • $LiveChatAPI->groups->get($group = 0)
  • $LiveChatAPI->groups->update($id, array $vars)
  • $LiveChatAPI->groups->add(array $vars)
  • $LiveChatAPI->groups->delete($id)

报告

报告REST API文档.

  • $LiveChatAPI->reports->get($type, array $params = array())

状态

状态REST API文档.

  • $LiveChatAPI->status->get($group = 0)

票证

票证REST API文档.

  • $LiveChatAPI->tickets->get(array $params = array())
  • $LiveChatAPI->tickets->getSingleTicket($ticketId)
  • $LiveChatAPI->tickets->add(array $vars)
  • $LiveChatAPI->tickets->updateTags($id, array $vars)

访客

访客REST API文档.

  • $LiveChatAPI->visitors->get(array $params = array())

标签

标签REST API文档.

  • $LiveChatAPI->tags->get($group=0)

  • $LiveChatAPI->tags->add(array( "author" => 'test@email.com', "tag" => 'Test Tag', "group" => 1 ))

  • $LiveChatAPI->tags->delete('Tag Name')

Webhooks

Webhooks REST API文档.

  • $LiveChatAPI->webhooks->get()

  • $LiveChatAPI->webhooks->add(array( "event_type" => "chat_started", "data_types" => array( "chat", "visitor" ), "url" => "http://www.shoeshop.com/webhook", ))

  • $LiveChatAPI->webhooks->delete('622d3950eecea8bb5f8c26f20c76ee2e')

待办事项

  • 模型测试
  • 添加所有支持的API方法