tprog / yii2-adwords-api
ADWords API 的扩展
dev-master
2019-04-14 16:54 UTC
Requires
This package is not auto-updated.
Last update: 2024-10-02 11:46:38 UTC
README
ADWords API 的扩展
安装
安装此扩展的首选方式是通过 composer。
运行以下命令之一:
php composer.phar require --prefer-dist tprog/yii2-adwords-api "*"
或者在您的 composer.json
文件的 require 部分添加:
"tprog/yii2-adwords-api": "*"
到 require 部分中。
配置
'components' => [
...
'ADwords' => [
'class' => 'tprog\adwordsapi\ADwords',
'developerToken' => '***************',
'server_version' => 'v201506',
'userAgent' => 'You Adwords API client',
'clientCustomerId' => '***-***-****',
'client' => [
'client_id' => '***************',
'client_secret' => '***************',
'refresh_token' => '***************',
],
],
...
使用
示例:创建新账户
$ADwordsUser = Yii::$app->ADwords->user; // Get the service, which loads the required classes. $managedCustomerService = $ADwordsUser->GetService('ManagedCustomerService'); // Create customer. $customer = new \ManagedCustomer(); $customer->name = 'Account #' . uniqid(); $customer->currencyCode = 'EUR'; $customer->dateTimeZone = 'Europe/London'; // Create operation. $operation = new \ManagedCustomerOperation(); $operation->operator = 'ADD'; $operation->operand = $customer; $operations = [$operation]; // Make the mutate request. $result = $managedCustomerService->mutate($operations); // Display result. $customer = $result->value[0]; printf("Account with customer ID '%s' was created.\n", $customer->customerId);