PHP code example of infobot / apiv2
1. Go to this page and download the library: Download infobot/apiv2 library . Choose the download type require .
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
infobot / apiv2 example snippets
composer
$client = new \Infobot\Api\Client($token);
$message = new \Infobot\Api\Messages\StaticMessage([
"to" => "79876543210",
"text" => "Сообщение",
"tts_voice" => "",
"tts_speed" => "",
]);
$response = $client->postMessages([
"body" => $message->toArray(),
]);
$message = new \Infobot\Api\Messages\DynamicMessage([
"to" => "79876543210",
"scenary" => 10,
]);
$response = $client->postMessages([
"body" => $message->toArray(),
]);
$message = new \Infobot\Api\Messages\AudioMessage([
"to" => "79876543210",
"audio" => "http://examle.site.com/audio.mp3",
]);
$response = $client->postMessages([
"body" => $message->toArray()
]);
$response = $client->getUsers();
$response = $client->getScenaries();
$response = $client->getScenaries([
"query" => ["page" => 1]
]);
$response = $client->getScenaries([
"query" => [":id" => 1]
]);
$response = $client->getStatisticsVariables([
"query" => ["message" => 1]
]);
$response = $client->getStatisticsVariables([
"query" => ["user" => 1]
]);
$response = $client->getStatisticsVariables([
"query" => ["phone" => 79876543210]
]);
$response = $client->getStatisticsVariables([
"query" => [
"phone" => 79876543210,
"page" => 1,
]
]);
$response = $client->getMessages();
$response = $client->getMessages([
"query" => ["page" => 1]
]);
$response = $client->getMessages([
"query" => [":id" => 1]
]);
$response = $client->deleteMessages([
"query" => [":id" => 1]
]);
$campaing = new Infobot\Api\Campaigns\BaseCampaigns("Рога и Копыта");
$response = $client->postCampaigns([
"body" => $campaing->toArray(),
]);
$campaing = new Infobot\Api\Campaigns\BaseCampaigns("Рога и Копыта 2.0");
$response = $client->patchCampaigns([
"query" => [":id" => 1],
"body" => $campaing->toArray(),
]);
$response = $client->getCampaigns();
$response = $client->getCampaigns([
"query" => [":id" => 1]
]);
$response = $client->getStatisticsFinance([
"query" => [
"overall",
":from" => гггг-мм-дд,
":to" => гггг-мм-дд,
":campaign_id" => 10
]
]);
$response = $client->postTrunks([
"query" => [
"activate"
],
"body" => [],
]);
$response = $client->getTrunks();
$response = $client->getTrunks([
"query" => [":id" => 1]
]);
$param = [
"channels" => "10",
"host" => "test.unknowntrunk.net",
"login" => "admin",
"password" => "qwerty",
"title" => "Тестовый транк",
];
$trunk = new \Infobot\Api\Trunks\BaseTrunk($param);
$response = $client->postTrunks([
"body" => $trunk->toArray(),
]);
$response = $client->deleteTrunks([
"query" => [":id" => 1]
]);
$param = [
"channels" => "10",
"host" => "test.unknowntrunk.net",
"login" => "admin",
"password" => "qwerty",
"title" => "Тестовый транк",
];
$trunk = new \Infobot\Api\Trunks\BaseTrunk($param);
$response = $client->patchTrunks([
"query" => [":id" => 1],
"body" => $trunk->toArray(),
]);
$response = $client->getDeliveries();
$response = $client->getDeliveries([
"query" => ["page" => 1]
]);
$response = $client->getDeliveries([
"query" => [":id" => 1]
]);
$response = $client->postDeliveries([
"query" => [":id" => 1],
"body" => [],
]);
$response = $client->postDeliveries([
"query" => [":id" => 1],
"body" => [],
]);
$params = [
"aon" => 79876543210,
"campaign_id" => 1,
"client_timezone" => true,
"d_type" => static,
"detect_voicemail" => false,
"group_id" => 1,
"message" => "static text",
"messages_per_packet" => 2,
"name" => "Моя рассылка",
"pause_between_packet" => 10,
"scenary_id" => '',
"speed" => 10,
"time_to_send_start" => "10:00",
"time_to_send_end" => "20:00",
"trunk" => 12,
"try_count" => 2,
"try_timeout" => 10,
"tts_speed" => 10,
"voice" => "male",
"file" => ''
];
$response = $client->postDeliveries([
"body" => $params,
]);
$params = [
"aon" => 79876543210,
"campaign_id" => 1,
"client_timezone" => true,
"d_type" => static,
"detect_voicemail" => false,
"group_id" => 1,
"message" => "static text",
"messages_per_packet" => 2,
"name" => "Моя рассылка",
"pause_between_packet" => 10,
"scenary_id" => '',
"speed" => 10,
"time_to_send_start" => "10:00",
"time_to_send_end" => "20:00",
"trunk" => 12,
"try_count" => 2,
"try_timeout" => 10,
"tts_speed" => 10,
"voice" => "male",
"file" => ''
];
$response = $client->patchDeliveries([
"query" => [":id" => 1],
"body" => $params,
]);
$response = $client->getGroups();
$response = $client->getGroups([
"query" => ["page" => 1]
]);
$response = $client->getGroups([
"query" => [":id" => 1]
]);
$params = [
"name" => "Имя группы"
];
$response = $client->postGroups([
"body" => $params,
]);
$params = [
"name" => "Имя группы"
];
$response = $client->patchGroups([
"query" => [":id" => 1],
"body" => $params,
]);
$response = $client->getContacts();
$response = $client->getContacts([
"query" => ["page" => 1]
]);
$response = $client->getContacts([
"query" => [":id" => 1]
]);
$response = $client->getContacts([
"query" => [
"group",
":group_id" => 1
]
]);
$response = $client->getContacts([
"query" => [
"group",
":group_id" => 1,
"page" => 1
]
]);
$params = [
"sex" => "male",
"group_ids" => [1,2,3],
"email" => "[email protected] ",
"fname" => "Фамилия",
"lname" => "Имя",
"mname" => "Отчество",
"phone" => "79876543210",
"var_1" => "var",
"var_2" => "var",
"var_3" => "var",
"var_4" => "var",
"var_5" => "var",
];
$response = $client->postContacts([
"body" => $params,
]);
$params = [
"sex" => "male",
"group_ids" => [1,3],
"email" => "[email protected] ",
"fname" => "Фамилия",
"lname" => "Имя",
"mname" => "Отчество",
"phone" => "79876543210",
"var_1" => "var",
"var_2" => "var",
"var_3" => "var",
"var_4" => "var",
"var_5" => "var",
];
$response = $client->patchContacts([
"query" => [":id" => 1],
"body" => $params,
]);