Skip to content

Latest commit

 

History

History
234 lines (173 loc) · 8.15 KB

File metadata and controls

234 lines (173 loc) · 8.15 KB

ChatApiCom\Client\ChatsApi

All URIs are relative to {protocol}://api.chat-api.com/instance{instanceId}

Method HTTP request Description
addGroupParticipant POST /addGroupParticipant Adding a participant to a group
creatGroup POST /group Creates a group and sends the message to the created group.
getChats GET /dialogs Get the chat list.
readChat POST /readChat Open chat for reading messages

addGroupParticipant

\ChatApiCom\Client\Model\AddGroupParticipantStatus addGroupParticipant($body, $group_id, $participant_chat_id, $participant_phone)

Adding a participant to a group

Example

<?php
require_once(__DIR__ . '/vendor/autoload.php');
// Configure API key authorization: token
$config = ChatApiCom\Client\Configuration::getDefaultConfiguration()
->setApiKey('token', 'YOUR_API_KEY')
->setInstanceId('YOUR_INSTANCE_ID');
// Uncomment below to setup prefix (e.g. Bearer) for API key, if needed
// $config = ChatApiCom\Client\Configuration::getDefaultConfiguration()->setApiKeyPrefix('token', 'Bearer');

$apiInstance = new ChatApiCom\Client\Api\ChatsApi(
    // If you want use custom http client, pass your client which implements `GuzzleHttp\ClientInterface`.
    // This is optional, `GuzzleHttp\Client` will be used as default.
    new GuzzleHttp\Client(),
    $config
);
$body = new \ChatApiCom\Client\Model\AddGroupParticipantAction(); // \ChatApiCom\Client\Model\AddGroupParticipantAction |
$group_id = "group_id_example"; // string | 
$participant_chat_id = "participant_chat_id_example"; // string | 
$participant_phone = 56; // int | 

try {
    $result = $apiInstance->addGroupParticipant($body, $group_id, $participant_chat_id, $participant_phone);
    print_r($result);
} catch (Exception $e) {
    echo 'Exception when calling ChatsApi->addGroupParticipant: ', $e->getMessage(), PHP_EOL;
}
?>

Parameters

Name Type Description Notes
body \ChatApiCom\Client\Model\AddGroupParticipantAction
group_id string [optional]
participant_chat_id string [optional]
participant_phone int [optional]

Return type

\ChatApiCom\Client\Model\AddGroupParticipantStatus

Authorization

token

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json

[Back to top] [Back to API list] [Back to Model list] [Back to README]

creatGroup

\ChatApiCom\Client\Model\CreateGroupStatus creatGroup($body, $group_name, $phones, $message_text)

Creates a group and sends the message to the created group.

The group will be added to the queue for sending and sooner or later it will be created, even if the phone is disconnected from the Internet or the authorization is not passed. 2 Oct 2018 update: chatId parameter will be returned if group was created on your phone within 20 second.

Example

<?php
require_once(__DIR__ . '/vendor/autoload.php');

$apiInstance = new ChatApiCom\Client\Api\ChatsApi(
    // If you want use custom http client, pass your client which implements `GuzzleHttp\ClientInterface`.
    // This is optional, `GuzzleHttp\Client` will be used as default.
    new GuzzleHttp\Client()
);
$body = new \ChatApiCom\Client\Model\CreateGroupAction(); // \ChatApiCom\Client\Model\CreateGroupAction |
$group_name = "group_name_example"; // string | 
$phones = array("phones_example"); // string[] | 
$message_text = "message_text_example"; // string | 

try {
    $result = $apiInstance->creatGroup($body, $group_name, $phones, $message_text);
    print_r($result);
} catch (Exception $e) {
    echo 'Exception when calling ChatsApi->creatGroup: ', $e->getMessage(), PHP_EOL;
}
?>

Parameters

Name Type Description Notes
body \ChatApiCom\Client\Model\CreateGroupAction
group_name string [optional]
phones string[] [optional]
message_text string [optional]

Return type

\ChatApiCom\Client\Model\CreateGroupStatus

Authorization

No authorization required

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json

[Back to top] [Back to API list] [Back to Model list] [Back to README]

getChats

\ChatApiCom\Client\Model\Chats getChats()

Get the chat list.

The chat list includes avatars.

Example

<?php
require_once(__DIR__ . '/vendor/autoload.php');
// Configure API key authorization: token
$config = ChatApiCom\Client\Configuration::getDefaultConfiguration()->setApiKey('token', 'YOUR_API_KEY');
// Uncomment below to setup prefix (e.g. Bearer) for API key, if needed
// $config = ChatApiCom\Client\Configuration::getDefaultConfiguration()->setApiKeyPrefix('token', 'Bearer');

$apiInstance = new ChatApiCom\Client\Api\ChatsApi(
    // If you want use custom http client, pass your client which implements `GuzzleHttp\ClientInterface`.
    // This is optional, `GuzzleHttp\Client` will be used as default.
    new GuzzleHttp\Client(),
    $config
);

try {
    $result = $apiInstance->getChats();
    print_r($result);
} catch (Exception $e) {
    echo 'Exception when calling ChatsApi->getChats: ', $e->getMessage(), PHP_EOL;
}
?>

Parameters

This endpoint does not need any parameter.

Return type

\ChatApiCom\Client\Model\Chats

Authorization

token

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json

[Back to top] [Back to API list] [Back to Model list] [Back to README]

readChat

\ChatApiCom\Client\Model\ReadChatStatus readChat($body, $chat_id, $phone)

Open chat for reading messages

Use this method to make users see their messages read.

Example

<?php
require_once(__DIR__ . '/vendor/autoload.php');
// Configure API key authorization: token
$config = ChatApiCom\Client\Configuration::getDefaultConfiguration()->setApiKey('token', 'YOUR_API_KEY');
// Uncomment below to setup prefix (e.g. Bearer) for API key, if needed
// $config = ChatApiCom\Client\Configuration::getDefaultConfiguration()->setApiKeyPrefix('token', 'Bearer');

$apiInstance = new ChatApiCom\Client\Api\ChatsApi(
    // If you want use custom http client, pass your client which implements `GuzzleHttp\ClientInterface`.
    // This is optional, `GuzzleHttp\Client` will be used as default.
    new GuzzleHttp\Client(),
    $config
);
$body = new \ChatApiCom\Client\Model\ReadChatAction(); // \ChatApiCom\Client\Model\ReadChatAction |
$chat_id = "chat_id_example"; // string | 
$phone = "phone_example"; // string | 

try {
    $result = $apiInstance->readChat($body, $chat_id, $phone);
    print_r($result);
} catch (Exception $e) {
    echo 'Exception when calling ChatsApi->readChat: ', $e->getMessage(), PHP_EOL;
}
?>

Parameters

Name Type Description Notes
body \ChatApiCom\Client\Model\ReadChatAction
chat_id string [optional]
phone string [optional]

Return type

\ChatApiCom\Client\Model\ReadChatStatus

Authorization

token

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json

[Back to top] [Back to API list] [Back to Model list] [Back to README]