Интерфейс для взаимодействия с клиентом Whatsapp
This PHP package is automatically generated by the Swagger Codegen project:
- API version: 1.0.0
- Build package: io.swagger.codegen.v3.generators.php.PhpClientCodegen For more information, please visit https://whatsgate.ru/
PHP 5.5 and later
To install the bindings via Composer, add the following to composer.json
:
{
"repositories": [
{
"type": "git",
"url": "https://github.com/GIT_USER_ID/GIT_REPO_ID.git"
}
],
"require": {
"GIT_USER_ID/GIT_REPO_ID": "*@dev"
}
}
Then run composer install
Download the files and include autoload.php
:
require_once('/path/to/SwaggerClient-php/vendor/autoload.php');
To run the unit tests:
composer install
./vendor/bin/phpunit
Please follow the installation procedure and then run the following:
<?php
require_once(__DIR__ . '/vendor/autoload.php');
// Configure API key authorization: ApiKeyAuth
$config = Swagger\Client\Configuration::getDefaultConfiguration()->setApiKey('X-API-Key', 'YOUR_API_KEY');
// Uncomment below to setup prefix (e.g. Bearer) for API key, if needed
// $config = Swagger\Client\Configuration::getDefaultConfiguration()->setApiKeyPrefix('X-API-Key', 'Bearer');
$apiInstance = new Swagger\Client\Api\DefaultApi(
// 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 \Swagger\Client\Model\CheckBody(); // \Swagger\Client\Model\CheckBody | Проверяет, зарегистрирован ли указанный номер в WhatsApp. Номер указывается в формате только цифр, например 79999999999
try {
$result = $apiInstance->checkPost($body);
print_r($result);
} catch (Exception $e) {
echo 'Exception when calling DefaultApi->checkPost: ', $e->getMessage(), PHP_EOL;
}
// Configure API key authorization: ApiKeyAuth
$config = Swagger\Client\Configuration::getDefaultConfiguration()->setApiKey('X-API-Key', 'YOUR_API_KEY');
// Uncomment below to setup prefix (e.g. Bearer) for API key, if needed
// $config = Swagger\Client\Configuration::getDefaultConfiguration()->setApiKeyPrefix('X-API-Key', 'Bearer');
$apiInstance = new Swagger\Client\Api\DefaultApi(
// 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 \Swagger\Client\Model\GetchatsBody(); // \Swagger\Client\Model\GetchatsBody | Запрашивает и возвращает список активных чатов, включая контакты и группы. В объекте группы находится идентификатор группы, список всех участников группы, права участников (является ли участник администратором группы).
try {
$result = $apiInstance->getChatsPost($body);
print_r($result);
} catch (Exception $e) {
echo 'Exception when calling DefaultApi->getChatsPost: ', $e->getMessage(), PHP_EOL;
}
// Configure API key authorization: ApiKeyAuth
$config = Swagger\Client\Configuration::getDefaultConfiguration()->setApiKey('X-API-Key', 'YOUR_API_KEY');
// Uncomment below to setup prefix (e.g. Bearer) for API key, if needed
// $config = Swagger\Client\Configuration::getDefaultConfiguration()->setApiKeyPrefix('X-API-Key', 'Bearer');
$apiInstance = new Swagger\Client\Api\DefaultApi(
// 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 \Swagger\Client\Model\SeenBody(); // \Swagger\Client\Model\SeenBody | Команда устанавливает у всех сообщений в указанном чате статус просмотрены.
try {
$result = $apiInstance->seenPost($body);
print_r($result);
} catch (Exception $e) {
echo 'Exception when calling DefaultApi->seenPost: ', $e->getMessage(), PHP_EOL;
}
// Configure API key authorization: ApiKeyAuth
$config = Swagger\Client\Configuration::getDefaultConfiguration()->setApiKey('X-API-Key', 'YOUR_API_KEY');
// Uncomment below to setup prefix (e.g. Bearer) for API key, if needed
// $config = Swagger\Client\Configuration::getDefaultConfiguration()->setApiKeyPrefix('X-API-Key', 'Bearer');
$apiInstance = new Swagger\Client\Api\DefaultApi(
// 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 \Swagger\Client\Model\SendBody(); // \Swagger\Client\Model\SendBody | Отправляет текстовое или мультимедийное сообщение контакту либо группе. Может использоваться синхронно (возвращает ответ после отправки сообщения, ответ содержит объект отправленного сообщения с идентификатором), либо асинхронно (ответ содержит результат постановки в очередь, а отправленное сообщение приходит на указанный webhook). По умолчанию используется асинхронная отправка.
try {
$result = $apiInstance->sendMessage($body);
print_r($result);
} catch (Exception $e) {
echo 'Exception when calling DefaultApi->sendMessage: ', $e->getMessage(), PHP_EOL;
}
?>
All URIs are relative to https://whatsgate.ru/v1
Class | Method | HTTP request | Description |
---|---|---|---|
DefaultApi | checkPost | POST /check | Проверка зарегистрирован ли номер в WhatsApp |
DefaultApi | getChatsPost | POST /get-chats | Возвращает список активных чатов |
DefaultApi | seenPost | POST /seen | Отправляет команду в чат, что последние сообщения просмотрены |
DefaultApi | sendMessage | POST /send | Отправка сообщения |
_Api | getMediaPost | POST /get-media | Возвращает объект медиафайла, прикрепленного к сообщению |
- AnyOfseenBodyRecipient
- AnyOfsendBodyMessage
- AnyOfsendBodyRecipient
- CheckBody
- Error
- GetchatsBody
- GetmediaBody
- InlineResponse200
- InlineResponse2001
- InlineResponse2002
- InlineResponse2003
- InlineResponse2004
- Media
- MessageMedia
- MessageText
- OneOfinlineResponse200Result
- RecipientId
- RecipientNum
- ResponseAsync
- ResponseChat
- ResponseChatGroupMetadata
- ResponseChatGroupMetadataParticipants
- ResponseMessage
- SeenBody
- SendBody
- Type: API key
- API key parameter name: X-API-Key
- Location: HTTP header