Hi adwords api team,
I am suffering with the same contents as below.
https://groups.google.com/forum/#!searchin/adwords-api/businessAccountIdentifier%7Csort:date/adwords-api/A-U_fRhquYw/tVoQ9sKsAgAJ
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' => '[email protected]'
'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());
}
}
--
--
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~
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/7e23fb02-b517-406f-bfe3-8add9ccae53a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.