PHP code example of cityads / api-client
1. Go to this page and download the library: Download cityads/api-client 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/ */
cityads / api-client example snippets
adsApiClientFactory = new \CityAds\Api\Factory\ClientFactory;
$clientId = 'client_id';
$clientSecret = 'client_secret';
//создание экземпляра клиента
$cityadsApiClient = $cityadsApiClientFactory->create($clientId, $clientSecret);
//GET-запрос на получение списка сущностей
$getListResponse = $cityadsApiClient->get(
'resourceName',
[
'sort' => 'id',
'sort_direction' => 'asc',
]
);
//GET-запрос на получение сущности по ее идентификатору
$getItemResponse = $cityadsApiClient->get(
'resourceName/{id}',
[
'sort' => 'id',
'sort_direction' => 'desc',
]
);
//POST-запрос на создание новой сущности
$postResponse = $cityadsApiClient->post(
'resourceName',
[
'entityName' => [
'some_field' => 125.56,
'another_field' => 'value',
],
]
);
//PATCH-запрос на редактирование сущности
$patchResponse = $cityadsApiClient->patch(
'resourceName/{id}',
[
"entityName" => [
"some_field" => 127,
],
]
);