dir.by  
Поиск >>

Компьютер, программы
→
Yandex сервисы для Web сайта (счетчик посещений, карта улиц, переводчик языков, контекстная реклама, ...)
→
Yandex Direct API (program code for managing advertising campaigns)
 Пример "Список комапний" php и Yandex Direct API (тестовая среда) 
посмотрели 13163 раз
Пример обращается к yandex API сервису campaigns и вызывается метод get доя получения списка компаний.
Чтобы пример заработал нужно:
1) получить доступ к Yandex Direct API ... и заргестрировать тестовые компании(Песочница).
2) Скачать пример в архиве ...
3) поменять YOUR-YANDEX-OAUTH-TOKEN
4) запустить пример
PHP пример:
<?php

// official site Request.php is: http://pear.php.net
require_once "HTTP/Request.php";

$url_path = "https://api-sandbox.direct.yandex.ru/json/v5/campaigns";

$token = "AQAAAAAN2SVf.............Ep8hEKrKQvO9AU"; ///// YOUR-YANDEX-OAUTH-TOKEN

$req =& new HTTP_Request($url_path);
$req->setMethod(HTTP_REQUEST_METHOD_POST);
$req->addHeader("Authorization", "Bearer $token");

// Параметры
$data = array();
$data["method"] = "get";
$data["params"] = utf8(
     array(
     "SelectionCriteria" => array("Ids" => array()),
     "FieldNames" => array("Name")
));

$json_data = json_encode($data);

$req->addRawPostData($json_data);

$response = $req->sendRequest();
$errmsg = PEAR::isError($response);

if (! $errmsg)
{
$result = $req->getResponseBody();
     $decoded_result = json_decode($result);
     print_r($decoded_result);
}
else
{
// Если ошибка произошла при попытке запроса
echo "Request error: ".$errmsg;
}

function utf8($struct)
{
     foreach ($struct as $key => $value)
     {
          if (is_array($value))
          {
               $struct[$key] = utf8($value);
          }
          elseif (is_string($value))
          {
               $struct[$key] = utf8_encode($value);
          }
     }
     return $struct;
}
?>
Screenshot
Документация Yandex Direct API
 
← Previous topic
Sandbox (test companies) Yandex Direct API
 
Next topic →
Access to Yandex Direct API
 
Your feedback ... Comments ...
   
Your Name
Your comment (www links can only be added by a logged-in user)

Новость "Черная пятница" Dreame в Беларуси – две недели скидок до 3400 рублей
 
Yandex Metrica (information about site visits)
• Information about site visits (how many visits, from which devices) Yandex Metrica
• How to add a visit counter (Yandex Metrica) to your website
Yandex Map (cities, streets)
• How to add a Yandex map to a website
Yandex Translate
• Yandex Translate API (language translator)
Yandex Direct (contextual advertising)
• Yandex Direct (what is contextual advertising?)
Yandex Direct API (program code for managing advertising campaigns)
• Access to Yandex Direct API (test environment)
• Sandbox (test companies) Yandex Direct API
• Example "List of companies" php and Yandex Direct API (test environment)
• Access to Yandex Direct API
• Establishment of the Company (on the direct.yandex.ru website)
• Financial Token
Yandex Advertising Network (YAN)
• Yandex Advertising Network (description) | How to join | Customize
• Adding Yandex ads to your site (vertical poster with 2 ads)
• Adding Yandex ads to your site (6 ads in a line, horizontal)
• Add a second site to the Yandex Advertising Network
Yandex Webmaster (site indexing, site links internal and external, etc.)
• What is Yandex Webmaster?
• How to add Yandex Webmaster to your website
Yandex Mail
• Yandex Mail (description)
Alice Talking Speaker Yandex
• I bought a Yandex speaker mini "Alice" and I want to connect it (I use an Android phone or iPhone)
• Column mini "Alice" view payment on the yandex website (you can change the plan, payment method)
Additionally
• How do I see the SQI (Site Quality Index) value for any site?

  Ваши вопросы присылайте по почте: info@dir.by