<?php // Reference to the service and version of the API you want to use
ini_set('display_errors', 1);ini_set('log_errors', 1);
define("ADWORDS_API_VERSION", "v201309");
// Production API
//define("ADWORDS_API_SERVER", "https://adwords.google.com");
// Sandbox API
define("ADWORDS_API_SERVER", "https://adwords.google.com");
define("ADWORDS_API_NAMESPACE",
"https://adwords.google.com/api/adwords/cm/" . ADWORDS_API_VERSION);
define("ADWORDS_API_CAMPAIGN_SERVICE", ADWORDS_API_SERVER .
"/api/adwords/cm/" . ADWORDS_API_VERSION . "/AdParamService");
// Your API Developer Token
define("ADWORDS_API_TOKEN", "ffrT**********************ZiA");
// The account that you want to download performace data from
$username = "[email protected]";
$password = "*****************";
$customerId = "576-859-5599";
try {
// Get an auth token for the user
$url = "https://www.google.com/accounts/ClientLogin";
$params = array(
"accountType" => "GOOGLE",
"Email" => $username,
"Passwd" => $password,
"service" => "adwords",
"source" => "test"
);
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, $url);
curl_setopt($curl, CURLOPT_HEADER, false);
curl_setopt($curl, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_POST, true);
curl_setopt($curl, CURLOPT_POSTFIELDS, $params);
curl_setopt($curl, CURLOPT_ENCODING, "");
$curlData = curl_exec($curl);
curl_close($curl);
$pos = strpos($curlData, "Auth=");
if ($pos > -1) {
$auth = trim(substr($curlData, $pos + 5));
} else {
throw new Exception("You haven't supplied a valid username or
password for an existing Google account.");
}
// Create the headers needed to access the API
$headers = array(
"developerToken" => ADWORDS_API_TOKEN,
"userAgent" => "Test",
"clientCustomerId" => $customerId,
"authToken" => $auth
);
// Encode the headers
$encodedHeaders = new SoapHeader(ADWORDS_API_NAMESPACE,
"RequestHeader", $headers, false);
// print_r($encodedHeaders);
// Create the selector
$request = array(
"get" => array(
"serviceSelector" => array(
"fields" => array("Id", "Name")
)
)
);
$bid1_soap=new SoapVar(NULL, NULL, 'money',ADWORDS_API_NAMESPACE);
print_r($bid1_soap);
$BiddingStrategyConfiguration=new SoapVar(NULL, NULL,
'BiddingStrategyConfiguration',ADWORDS_API_NAMESPACE);
print_r($BiddingStrategyConfiguration);
//for ($i = 0; $i < 6; $i++) {
$keywords = array(
"mutate" => array(
'BiddingStrategyConfiguration' => new SoapVar(NULL, NULL,
'BiddingStrategyConfiguration',ADWORDS_API_NAMESPACE),
"adGroupId"=>"8424820921",
"userStatus"=>"PAUSED",
"destinationUrl"=>"http://www.cartouche-encre.biz/toner-couleur/toner-canon",
"criterion"=>array(
"text"=>"xp 205",
"matchType"=>'BROAD'
)
)
);
$operation = array('operator' => 'ADD', 'operand' => $keywords);
$operations = array($operation);
/* $request = array(
"mutate" => array(
"operations" => array(
array("operator"=>"SET","operand"=>array("id"=>$adgroupidx,"biddingStrategyConfiguration"=>array("bids"=>array($bid2_soap)))
)
)
//--operations
)
//---mutate
);
//---request
//} */
echo ('****************');
// Create the SOAP client
$client = new SoapClient(ADWORDS_API_CAMPAIGN_SERVICE . "?wsdl",
array("trace" => true));
//print_r ($client);
echo ADWORDS_API_CAMPAIGN_SERVICE . "?wsdl";
var_dump($client->__getFunctions());
//$result = $client->mutate($operations);
// Get the campaigns
$result = $client->__soapCall("mutate", $operations,null
,$encodedHeaders);
print_r($result);
// Output the results
$campaigns = $result->rval->entries;
/* foreach ($campaigns as $campaign) {
print "<br>Found campaign '{$campaign->name}' with an ID of
{$campaign->id}\n<br>";
} */
} catch (Exception $e) {
print_r($e);
if (isset($client)) {
print $client->__getLastRequest() . "\n";
print $client->__getLastResponse() . "\n";
}
}
*************************************************
result:
https://adwords.google.com/api/adwords/cm/v201309/AdGroupCriterionService?wsdlarray(2)
{ [0]=> string(32) "getResponse get(get $parameters)" [1]=> string(41)
"mutateResponse mutate(mutate $parameters)" [2]=> string(38) "queryResponse
query(query $parameters)"}SoapFault Object( [message:protected] =>
[NotEmptyError.EMPTY_LIST @ operations] [string:Exception:private] =>
[code:protected] => 0 [file:protected] =>
/var/www/vhosts/cartouche-discount.com/httpdocs/adwords_api_php_4.6.1/addKeywords.php
[line:protected] => 137 [trace:Exception:private] => Array (
[0] => Array ( [file] =>
/var/www/vhosts/cartouche-discount.com/httpdocs/adwords_api_php_4.6.1/addKeywords.php
[line] => 137 [function] => __soapCall
[class] => SoapClient [type] => ->
[args] => Array (
[0] => mutate [1] => Array
( [0] => Array
( [operator] => ADD
[operand] => Array
(
[mutate] => Array (
[biddingStrategy] =>
SoapVar Object (
[enc_type]
=> 999998
[enc_stype] => BiddingStrategyConfiguration
[enc_ns] =>
https://adwords.google.com/api/adwords/cm/v201309
)
[adGroupId] => 8424820921
[userStatus] => PAUSED
[destinationUrl] =>
http://www.cartouche-encre.biz/toner-couleur/toner-canon
[criterion] => Array
(
[text] => xp 205
[matchType] => BROAD
)
) )
) )
[2] => [3] => SoapHeader Object
( [namespace] =>
https://adwords.google.com/api/adwords/cm/v201309
[name] => RequestHeader [data] => Array
(
[developerToken] => f********************sZiA
[userAgent] => Test
[clientCustomerId] => 576-859-5699
[authToken] =>
DQAAANIAAACzSYVQX-******************************************************IwXoyXRlcHw4ewuajDS5F4LhduY6IsUlY6mmfO5r97FQ918bm_l6_b4eXrUi9j0i50iC2mRFo9rDAJ3GZkwjrdds4gDo1PSyloh5QjxCpKxfpP3MpuKUaQeYvXRnOMu8KeizZoMmpglu6rWENprgiBvtsGzzjyVT8ojFF2DVzAo6GEgO9K2LCGW33_MuQ6-CaAuUTt0DxUwFwNNnNuRLUM9eDbgKS7ew
)
[mustUnderstand] => ) )
) ) [previous:Exception:private] => [faultstring]
=> [NotEmptyError.EMPTY_LIST @ operations] [faultcode] => soap:Server
[detail] => stdClass Object ( [ApiExceptionFault] => stdClass
Object ( [message] =>
[NotEmptyError.EMPTY_LIST @ operations]
[ApplicationException.Type] => ApiException [errors] =>
SoapVar Object ( [enc_type]
=> 0 [enc_value] => stdClass Object
( [fieldPath] => operations
[trigger] =>
[errorString] => NotEmptyError.EMPTY_LIST
[ApiError.Type] => NotEmptyError [reason] =>
EMPTY_LIST )
[enc_stype] => NotEmptyError [enc_ns] =>
https://adwords.google.com/api/adwords/cm/v201309 )
) ))
--
--
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~
Also find us on our blog and discussion group:
http://googleadsdeveloper.blogspot.com
http://groups.google.com/group/adwords-api
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~
You received this message because you are subscribed to the Google
Groups "AdWords API Forum" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/adwords-api?hl=en
---
You received this message because you are subscribed to the Google Groups
"AdWords API Forum" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.