In my php app, I'm trying to find adwords account activity via
CustomerSyncService API. This works fine with few customer clients, but
fail with one client. Also it was working fine for this specific client
till 3 days ago.
Error I got is this :
> [SoapFault] [InternalApiError.UNEXPECTED_INTERNAL_API_ERROR @
> com.google.ads.api.services.common.error.InternalApiError.<init>(InternalApiErro]
Any reason ?
related code (don't look for typos, it is working fine in other cases):
private function downloadCSVReportActivity($access_token, $expires_in,
$timestamp, $clientCustomerId, $fromDate, $toDate) {
$user = new \AdWordsUser();
$user->LogAll();
$user->SetClientCustomerId($clientCustomerId);
$oAuth2Info = $user->GetOAuth2Info();
//SET access token value in oauth..
//thsi is required while using new service
$oAuth2Info['access_token'] = $access_token;
$oAuth2Info['expires_in'] = $expires_in;
$oAuth2Info['timestamp'] = $timestamp;
// Download report.
$user->SetOAuth2Info($oAuth2Info);
$campaignService = $user->GetService('CampaignService', "v201605");
$customerSyncService = $user->GetService('CustomerSyncService',
"v201605");
// Get an array of all campaign ids.
$campaignIds = array();
$selector = new \Selector();
$selector->fields = array('Id', 'Name', 'Status');
$selector->paging = new \Paging(0, 500);
$selector->predicates[] = new \Predicate('Status', 'IN', array(
'ENABLED'));
do {
$page = $campaignService->get($selector);
if (isset($page->entries)) {
foreach ($page->entries as $campaign) {
//get all campaign id corresponding to its name
$campaignIds[$campaign->id] = $campaign->name;
}
}
$selector->paging->startIndex += 500;
} while ($page->totalNumEntries > $selector->paging->startIndex);
$activityGraphArr = array();
// Set the date time range, from 24 hours ago until now.
$dateTimeRange = new \DateTimeRange();
//initialize the count to 0
if(!empty($campaignIds)){
//bug fixed: display account activity for 90 days instead of 12
weeks
try{
for ($i = 0; $i < 12; $i++) {
$count = 0;
//fetch data weekly.. so set date by subtracting the days
from min nd max date
$subDays = 7 * $i;
$fdate = date('Y-m-d', strtotime('-' . $subDays . 'day',
strtotime($fromDate)));
$tdate = date('Y-m-d', strtotime('-' . $subDays . 'day',
strtotime($toDate)));
$dateTimeRange->min = date('Ymd his', strtotime($fdate));
$dateTimeRange->max = date('Ymd his', strtotime($tdate));
// Create selector.
//get customer acc setting from $customerSyncService
$selector = new \CustomerSyncSelector();
$selector->dateTimeRange = $dateTimeRange;
$selector->campaignIds = array_keys($campaignIds);
// Make the get request.
$accountChanges = $customerSyncService->get($selector);
if (isset($accountChanges)) {
foreach ($accountChanges->changedCampaigns as
$campaignChangeData) {
if ($campaignChangeData->campaignChangeStatus !=
'NEW') {
//add all the changes to get the total number
of times changes
//are made
$count +=!empty($campaignChangeData->
removedAdExtensions) ?
sizeOf($campaignChangeData->
removedAdExtensions) : 0;
$count +=!empty($campaignChangeData->
addedCampaignCriteria) ?
sizeOf($campaignChangeData->
addedCampaignCriteria) : 0;
$count +=!empty($campaignChangeData->
removedCampaignCriteria) ?
sizeOf($campaignChangeData->
removedCampaignCriteria) : 0;
if (isset($campaignChangeData->changedAdGroups))
{
foreach ($campaignChangeData->changedAdGroups
as $adGroupChangeData) {
if ($adGroupChangeData->adGroupChangeStatus
!= 'NEW') {
$count +=!empty($adGroupChangeData
->changedAds) ?
sizeOf($adGroupChangeData->
changedAds) : 0;
}
}
}
}
}
//push date and count into array
$graphArr[0] = $fdate;
$graphArr[1] = $count;
array_push($activityGraphArr, $graphArr);
}
}
}catch (Exception $ex) {
$this->log($ex->getMessage(), "error");
}
}
return $activityGraphArr;
}
--
--
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~
Also find us on our blog and Google+:
https://googleadsdeveloper.blogspot.com/
https://plus.google.com/+GoogleAdsDevelopers/posts
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~
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].
Visit this group at https://groups.google.com/group/adwords-api.
To view this discussion on the web visit
https://groups.google.com/d/msgid/adwords-api/de62d9ff-cab1-4928-91fd-a8d53a069d76%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.