Dan,
Our you sure you have properly setup a campaign with an adgroup in the
sandbox? The first error is related to the data returned from your
AdGroup. I see you have an AdGroup ID (<adGroupId>5100452329</
adGroupId>) but that may not mean that there is any other information
to return. The code block in AdGroup.inc.php (line 137) is creating
an array object that would then output to the display. I'm guessing
that there isn't anything to output and so the foreach() function is
generating the warning.
Also, I don't recall adding the email to the developers token in the
sandbox. It's been awhile since I've used the sandbox, but I think
the Dev token would just be the token string no email. Reference this
line in your getLastSoapRequests() response:
<developerToken>email@address++GBP</developerToken>
Here is a simple script to test the presence of an adgroup:
<?php
session_start();
require_once("apility.php");
require ("adminkey.inc.php");
/**
* @author October Design Inc.
* This script is used to identify campaign data that would be useful
for other web pages
* Use this page to get adgroup information
*/
//create short variables from DEFINE constants
//if constants are not defined elsewhere, assign the variable a string
$admin = MCC_USER; //your email
$pass = MCC_PWD; //your password
$appToken = GAPI_APP; //application token
$devToken = GAPI_DEV; //developers token
$clientacc = CACCT; //clients email
$campid = CID; //clients campaign id
//set date range for reports,
//sets start date for the report to 7 days ago, start from 7 days ago
$startday = gmdate(
"Y-m-d",
mktime(
date("H"),
date("i"),
date("s"),
date("m"),
date("d") - 7,
date("Y")
)
);
//sets end date to yesterday
$endday = gmdate(
"Y-m-d",
mktime(
date("H"),
date("i"),
date("s"),
date("m"),
date("d") - 1,
date("Y")
)
);
//create a new apilityUser object from the APIlityUser class
$apilityUser = new APIlityUser(
$admin,
$pass,
$clientacc,
$devToken,
$appToken);
//get AdGroup information
echo "AdGroup information for ".$clientacc;
//returns an Array of the AdGroup object, one entry for each AdGroup
$activeAdGroups = getActiveAdGroups("$campid");
echo "<pre>";
print_r($activeAdGroups);
echo "</pre>";
echo "<br>";
//operate on the AdGroup object
$adGroupObject = createAdGroupObject($activeAdGroups[0]['id']);
echo $adGroupObject->getName();
?>
Should return something like this:
Here are the campaign parameters for em...@domain.com
Array
(
[0] => APIlityAdGroup Object
(
[keywordMaxCpc] => 3.25
[siteMaxCpm] =>
[siteMaxCpc] => 0.75
[maxCpa] =>
[keywordContentMaxCpc] => 0.75
[proxyKeywordMaxCpc] =>
[name] => Name of the AdGroup
[id] => 112233445566778899
[belongsToCampaignId] => 1234567890
[status] => Enabled
)
)
Hope that helps
rwhite35
On Oct 27, 5:30 am, Dan <daniel.pl...@gmail.com> wrote:
> Hi,
> I'm getting a very unusual problem, that I have come across with
> Apility v13 before. (in the sandbox, not tried live yet)
> The actual apility errors are:
> Warning: Invalid argument supplied for foreach() in /path/to/
> apility_1.13.1/lib/AdGroup.inc.php on line 137
> Warning: Invalid argument supplied for foreach() in /path/to/
> apility_1.13.1/lib/Criterion.inc.php on line 106
> These errors look like I am getting nothing back from my soap
> requests.
> print_r(getLastSoapRequests());
> <?xml version="1.0" encoding="UTF-8"?><SOAP-ENV:Envelope xmlns:SOAP-
> ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-
> instance" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/"
> xmlns:ns3044="http://tempuri.org"><SOAP-
> ENV:Header><email>email@address</email>
> <password>password</password>
> <clientEmail>client_2+email@address</clientEmail>
> <developerToken>email@address++GBP</developerToken>
> <applicationToken></applicationToken>
> <useragent>Google APIlity PHP Library for AdWords</useragent></SOAP-
> ENV:Header>
> <SOAP-ENV:Body><addCriteria><criteria>
> <adGroupId>5100452329
> </adGroupId>
> <type>Phrase</type>
> <criterionType>Keyword</criterionType>
> <text>keyword here</text>
> <negative>false</negative>
> <language>en</language>
> <destinationUrl></destinationUrl><exemptionRequest>
> </exemptionRequest></criteria>
> ... 21 more criterion
> </addCriteria></SOAP-ENV:Body></SOAP-ENV:Envelope>
> print_r(getLastSoapResponses());
> was empty..
> After Googling, I read that "upload_max_filesize" and "post_max_size"
> could have an effect, so I set them to 512M.
> I am at a lost to understand (and fix), why my requests are coming
> back blank.
> One final thing I did notice was one of my borked requests, did
> produce a result, however it was slightly corrupted..
> Array ( [0] => ô’€n charset=utf-8
> Transfer-Encoding: chunked
> Date: Mon, 26 Oct 2009 19:59:44 GMT
> Expires: Mon, 26 Oct 2009 19:59:44 GMT
> Cache-Control: private, max-age=0
> X-Content-Type-Options: nosniff
> X-XSS-Protection: 0
> Server: GFE/2.0
> <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/
> envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema"
> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
> <soapenv:Header>
> <responseTime soapenv:actor="http://schemas.xmlsoap.org/soap/actor/
> next" soapenv:mustUnderstand="0" xmlns="https://adwords.google.com/api/
> adwords/v13">194</responseTime>
> <operations soapenv:actor="http://schemas.xmlsoap.org/soap/actor/next"
> soapenv:mustUnderstand="0" xmlns="https://adwords.google.com/api/
> adwords/v13">48</operations>
> <units soapenv:actor="http://schemas.xmlsoap.org/soap/actor/next"
> soapenv:mustUnderstand="0" xmlns="https://adwords.google.com/api/
> adwords/v13">48</units>
> <requestId soapenv:actor="http://schemas.xmlsoap.org/soap/actor/next"
> soapenv:mustUnderstand="0" xmlns="https://adwords.google.com/api/
> adwords/v13">13af0e391a08c5c189ac7ea00a585a2f</requestId>
> </soapenv:Header>
> <soapenv:Body>
> <addCriteriaResponse xmlns="">
> .. criteria
> <ns35:addCriteriaReturn xsi:type="ns35:Keyword" xmlns:ns35="https://
> adwords.google.com/api/adwords/v13">
> <ns35:adGroupId>5100455065</ns35:adGroupId>
> <ns35:criterionType>Keyword</ns35:cr
> and then it just stopped... the total length of the response was
> 21,065 bytes (give or take a few bytes).
> Any help would be gratefully appreciated.
> Thanks
> Dan