bubnov/yandex-direct-client 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

bubnov/yandex-direct-client

Composer 安装命令:

composer require bubnov/yandex-direct-client

包简介

PHP lib for Yandex Direct API

README 文档

README

Требует curl-расширение!

Пакет для работы с сервисом Яндекс.Direct посредством его API.

  • Подготовлен к использованию через Composer
  • Определен автолоадер (согласно psr-4)
  • Доступны все методы API
  • Дополнительно перед отправкой проводится валидация входных данных через json-schema (База наполняется)
  1. Установка Composer
composer require bubnov/yandex-direct-client
  1. Использование
<?php
require 'vendor/autoload.php';

$authKey = 'MY-AUTH-TOKEN';

$client = new YandexDirectClient\Client($authKey);

try {
    /**
     * Getting Units for users
     */
    $response = $client->GetClientsUnits(['my-user','customer-user']);
    
    /**
     * If Response is an array - you can access to each element as in array
     */
    foreach($response as $item){
        /**
         * If the item has a property (see Yandex Direct API docs) - you can access it by getter
         */
        echo "\n" . $item->getLogin() . " has units: " . $item->getUnitsRest();
    }

    /**
     * Or you can access directly Nth element in array
     */
    echo "\nFirst user units: " . $response->get(0)->getUnitsRest();
    
    /**
     * Generating WordstatReport
     */
    $reportId = $client->CreateNewWordstatReport(['Phrases' => ['Купить холодильник', 'Холодильники недорого']]);
    echo "\nReportId: " . $reportId;
    
    /**
     * Wait for 10 seconds
     */
    sleep(10);
    
    /**
     * Getting full reports list
     */
    $reports = $client->GetWordstatReportList();
    foreach($reports as $report){
        /**
         * Find report with $reportId and status 'Done'
         */
        if($report->getReportID() == $reportId && $report->getStatusReport() === 'Done'){
            echo "\nReport is done, reading";
            break;
        }
    }
    
    /**
     * Get wordstat report by $reportId
     */
    $report = $client->GetWordstatReport($reportId);
    foreach($report as $reportPart){
        foreach($reportPart->getSearchedWith() as $searchedWith){
            echo sprintf(
                "\nPhrase `%s` has %d shows \n", 
                $searchedWith->getPhrase(), 
                $searchedWith->getShows()
            );
        }
    }
    
    /**
     * Deleting wordstat report
     */
    $status = $client->DeleteWordstatReport($reportId);
    echo $status ? "\nReport successfully deleted" : "\nSomething wrong...";
}
catch (\YandexDirectClient\Exceptions\YandexErrorException $e){
    echo "\nYandexErrorException: " . $e->getMessage() . "\nWith details: " . $e->getErrorDetail() . "\n";
}
catch (\Exception $e){
    echo "\nException: " . $e->getMessage() . "\n";
}
  1. TODO

Расширение json schema для методов

统计信息

  • 总下载量: 184
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 1
  • 点击次数: 5
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 1
  • Watchers: 3
  • Forks: 4
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2017-01-23

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固