AdWords location extensions

72 views
Skip to first unread message

test71942

unread,
Dec 12, 2017, 4:35:39 AM12/12/17
to AdWords API Forum
Hi adwords api team,

I am suffering with the same contents as below.

An error occurs by calling 「setBusinessAccountIdentifier」.

(1/1) ApiException

[InternalApiError.UNEXPECTED_INTERNAL_API_ERROR @ com.google.ads.api.services.common.error.InternalApiError.<init>(InternalApiErro]



We kindly ask for your cooperation.
thank you.


$userLocations = [];
$userAccounts = [];
foreach($gooleMyBusiness->accounts->listAccounts() as $account) {
$locations = $gooleMyBusiness->accounts_locations->listAccountsLocations($account->name);
$userAccounts[] = $account;
foreach($locations->getLocations() as $location) {
$userLocations[] = $location;
}
}
$this->dispatch(
new AssociationGoogleMyBusinessLocationExtensions([
'gmbEmailAddress' => 'te...@gmail.com'
'gmbBusinessAccountId' => explode('/', $userAccounts[0]->name)[1],
], $adwordsAccount)
);

ーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーー

class AssociationGoogleMyBusinessLocationExtensions
{
use DispatchesJobs;

protected $_params;
protected $_adWordsServices;
protected $_session;

const PLACEHOLDER_LOCATION = 7;

// The maximum number of CustomerFeed ADD operation attempts to make before
// throwing an exception.
const MAX_CUSTOMER_FEED_ADD_ATTEMPTS = 10;

const BUSINESS_ACCOUNT_IDENTIFIER = null;

/**
* Create a new command instance.
*
* @param array $params
*/
public function __construct(array $params, $adwordsAccount)
{
$this->_params = $params;

$oAuth2Credential = (new OAuth2TokenBuilder())
->fromFile()
->build();

$this->_gmbAccessToken = $oAuth2Credential->fetchAuthToken()['access_token'];

$session = (new AdWordsSessionBuilder())
->fromFile()
->withOAuth2Credential($oAuth2Credential)
->withClientCustomerId($adwordsAccount->account_id)
->withSoapLogger(new Logger('', [new NullHandler()]))
->withReportDownloaderLogger(new Logger('', [new NullHandler()]))
->build();

$this->_session = $session;

$this->_adWordsServices = new AdWordsServices;
}

/**
* @return \App\ORM\Customer
*
*/
public function handle()
{
//dd($this->_params);
$feedService = $this->_adWordsServices->get($this->_session, FeedService::class);
// Create a feed that will sync to the Google My Business account specified
// by $gmbEmailAddress. Do not add FeedAttributes to this object, as AdWords
// will add them automatically because this will be a system generated feed.
//dd($this->_params);
$gmbFeed = new Feed();
$gmbFeed->setName('Google My Business feed #' . uniqid());
$feedData = new PlacesLocationFeedData();
$feedData->setEmailAddress($this->_params['gmbEmailAddress']);
//$feedData->setBusinessAccountIdentifier(Null);
$feedData->setBusinessAccountIdentifier($this->_params['gmbBusinessAccountId']);
//$feedData->setBusinessAccountIdentifier($this->_params['gmbBusinessAccountId']);
// Optional: specify labels to filter Google My Business listings. If
// specified, only listings that have any of the labels set are
// synchronized into FeedItems.
$feedData->setLabelFilters(['Stores in New York City']);

$oAuthInfo = new OAuthInfo();
$oAuthInfo->setHttpMethod('GET');
$oAuthInfo->setHttpRequestUrl('https://www.googleapis.com/auth/adwords');
$oAuthInfo->setHttpAuthorizationHeader(
sprintf('Bearer %s', $this->_gmbAccessToken));

$feedData->setOAuthInfo($oAuthInfo);
$gmbFeed->setSystemFeedGenerationData($feedData);
// Since this feed's feed items will be managed by AdWords,
// you must set its origin to ADWORDS.
$gmbFeed->setOrigin(FeedOrigin::ADWORDS);
// Create a feed operation and add it to the list.
$operation = new FeedOperation();
$operation->setOperator(Operator::ADD);
$operation->setOperand($gmbFeed);
$operations = [$operation];
// Add the feed on the server. Since it is a system generated feed, AdWords
// will automatically:
// 1. Set up the FeedAttributes on the feed.
// 2. Set up a FeedMapping that associates the FeedAttributes of the feed
// with the placeholder fields of the LOCATION placeholder type.
$addedFeed = $feedService->mutate($operations)->getValue()[0];
printf("Added GMB feed with ID %d\n", $addedFeed->getId());
}

}

Sreelakshmi Sasidharan (AdWords API Team)

unread,
Dec 12, 2017, 1:00:51 PM12/12/17
to AdWords API Forum
Hi, 

As described on this forum thread, could you confirm if you are using your GMB business account or a GMB personal account? If you are using the GMB business account, could you please enable logging and share the complete SOAP request and response? 

Thanks,
Sreelakshmi, AdWords API Team

kenta

unread,
Dec 13, 2017, 12:01:14 AM12/13/17
to AdWords API Forum
Hi Sreelakshmi Sasidharan,

I wrote the response information and the request information.
Individual id etc are erased.

Thanks,
Kenta

---------------------------------------------------------------------------------------------------------------------

AW_SOAP.NOTICE: POST /api/adwords/cm/v201710/FeedService?wsdl HTTP/1.1^M
Connection: close^M
User-Agent: PHP-SOAP/7.0.26^M
Content-Type: text/xml; charset=utf-8^M
SOAPAction: ""^M

Content-Length: 1513^M
Authorization: REDACTED

<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="https://adwords.google.com/api/adwords/cm/v201710" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"><SOAP-ENV:Header><ns1:RequestHeader><ns1:clientCustomerId>xxxxxxxxxxxxx</ns1:clientCustomerId><ns1:developerToken>REDACTED</ns1:developerToken><ns1:userAgent>unknown (AwApi-PHP, googleads-php-lib/32.1.0, PHP/7.0.26)</ns1:userAgent><ns1:validateOnly>false</ns1:validateOnly><ns1:partialFailure>false</ns1:partialFailure></ns1:RequestHeader></SOAP-ENV:Header><SOAP-ENV:Body><ns1:mutate><ns1:operations><ns1:operator>ADD</ns1:operator><ns1:operand><ns1:name>Google My Business feed #5a3097630001a</ns1:name><ns1:origin>ADWORDS</ns1:origin><ns1:systemFeedGenerationData xsi:type="ns1:PlacesLocationFeedData"><ns1:oAuthInfo><ns1:httpMethod>GET</ns1:httpMethod><ns1:httpRequestUrl>https://www.googleapis.com/auth/adwords</ns1:httpRequestUrl><ns1:httpAuthorizationHeader>REDACTED</ns1:httpAuthorizationHeader></ns1:oAuthInfo><ns1:emailAddress>xxxxxxxxx...@gmail.com</ns1:emailAddress><ns1:businessAccountIdentifier>xxxxxxxxxxxxxxxxxx</ns1:businessAccountIdentifier><ns1:labelFilters>Stores in New York City</ns1:labelFilters></ns1:systemFeedGenerationData></ns1:operand></ns1:operations></ns1:mutate></SOAP-ENV:Body></SOAP-ENV:Envelope>


HTTP/1.1 500 Internal Server Error^M
Content-Type: text/xml; charset=UTF-8^M
Date: Wed, 13 Dec 2017 02:58:44 GMT^M
Expires: Wed, 13 Dec 2017 02:58:44 GMT^M
Cache-Control: private, max-age=0^M
X-Content-Type-Options: nosniff^M
X-Frame-Options: SAMEORIGIN^M
X-XSS-Protection: 1; mode=block^M
Server: GSE^M
Alt-Svc: hq=":443"; ma=2592000; quic=51303431; quic=51303339; quic=51303338; quic=51303337; quic=51303335,quic=":443"; ma=2592000; v="41,39,38,37,35"^M
Accept-Ranges: none^M
Vary: Accept-Encoding^M
Connection: close

<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"><soap:Header><ResponseHeader xmlns="https://adwords.google.com/api/adwords/cm/v201710"><requestId>0005602ff20612d80a621019e506cb32</requestId><serviceName>FeedService</serviceName><methodName>mutate</methodName><operations>1</operations><responseTime>1105</responseTime></ResponseHeader></soap:Header><soap:Body><soap:Fault><faultcode>soap:Server</faultcode><faultstring>[InternalApiError.UNEXPECTED_INTERNAL_API_ERROR @ com.google.ads.api.services.common.error.InternalApiError.&lt;init&gt;(InternalApiErro]</faultstring><detail><ApiExceptionFault xmlns="https://adwords.google.com/api/adwords/cm/v201710"><message>[InternalApiError.UNEXPECTED_INTERNAL_API_ERROR @ com.google.ads.api.services.common.error.InternalApiError.&lt;init&gt;(InternalApiErro]</message><ApplicationException.Type>ApiException</ApplicationException.Type><errors xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="InternalApiError"><fieldPath></fieldPath><trigger></trigger><errorString>InternalApiError.UNEXPECTED_INTERNAL_API_ERROR</errorString><ApiError.Type>InternalApiError</ApiError.Type><reason>UNEXPECTED_INTERNAL_API_ERROR</reason></errors></ApiExceptionFault></detail></soap:Fault></soap:Body></soap:Envelope>



2017年12月13日水曜日 3時00分51秒 UTC+9 Sreelakshmi Sasidharan (AdWords API Team):

Sreelakshmi Sasidharan (AdWords API Team)

unread,
Dec 13, 2017, 1:58:53 PM12/13/17
to AdWords API Forum
Hi, 

Could you please reply privately to author and share the client customer id of your AdWords account and the businessAccountIdentifier of your GMB account?
Reply all
Reply to author
Forward
0 new messages