[PHP] Google Ads - How to link an existing Google Adwords (or Ads) Account to my Google Ads MCC ?

648 views
Skip to first unread message

ludovic...@gmail.com

unread,
Feb 13, 2019, 6:02:37 AM2/13/19
to AdWords API and Google Ads API Forum
Hi,

I would like to link an existing Google Adwords (or Ads) Account to my Google Ads MCC with PHP, but i can't find any code example.
What can i do please ? Someone have already done that ?

Cheers.

googleadsapi...@google.com

unread,
Feb 13, 2019, 2:40:01 PM2/13/19
to AdWords API and Google Ads API Forum
Hello,

To link the accounts, you can use the ManagedCustomerService.mutateLink API call. For more information, please refer to this document. You can find the code samples in that document. Let me know if you have any further questions. 

Thanks,
Milind, AdWords API Team
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~
Also find us on our blog and discussion group:
    http://googleadsdeveloper.blogspot.com/search/label/adwords_api
    https://developers.google.com/adwords/api/community/
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~

Was your question answered? Please rate your experience with us by taking a short survey.
If not -- reply to this email and tell us what else we can do to help.

Take Survey

Also find us on our blog and discussion group:
http://googleadsdeveloper.blogspot.com/search/label/adwords_api
https://developers.google.com/adwords/api/community/

ludovic...@gmail.com

unread,
Feb 14, 2019, 3:08:06 AM2/14/19
to AdWords API and Google Ads API Forum
Hi, thank's for your answer, but you give me some examples from Adwords, and i need that for Ads. It's impossible to find some sample code ?
Google documentation is too difficult to understand, why they don't give the code ? Because they only explain the concept.
Please i really need help for that.

Cheers.

googleadsapi...@google.com

unread,
Feb 14, 2019, 3:59:50 PM2/14/19
to ludovic...@gmail.com, AdWords API and Google Ads API Forum
Hello,

To clarify, are you looking to link existing Ads from another account to manager account? If yes, then you won't be able to link Ads to Manager accounts directly. However, you will need to link account which contain that Ads to your manger account. To link accounts, you can find the sample code under 'Extending invitations' section in this document. Once you link both the accounts, the manager account can manage the Ads using AdWords API.

If this is not what you are looking for, then could you please elaborate for which scenario do you need the PHP code for? 


Thanks,
Milind, AdWords API Team
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~
Also find us on our blog and discussion group:
    http://googleadsdeveloper.blogspot.com/search/label/adwords_api
    https://developers.google.com/adwords/api/community/
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~

--
--
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~
Also find us on our blog:
https://googleadsdeveloper.blogspot.com/
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~
 
You received this message because you are subscribed to the Google
Groups "AdWords API and Google Ads API Forum" group.
To post to this group, send email to adwor...@googlegroups.com
To unsubscribe from this group, send email to
adwords-api+unsubscribe@googlegroups.com
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 and Google Ads API Forum" group.
To unsubscribe from this group and stop receiving emails from it, send an email to adwords-api+unsubscribe@googlegroups.com.
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/925292a9-e33e-4a5d-8edb-f2eb9f1092f4%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

ludovic...@gmail.com

unread,
Feb 15, 2019, 9:00:20 AM2/15/19
to AdWords API and Google Ads API Forum
Hi, the challenge is to only use the Google Ads API lib, i can't use the Google Adwords API.
So what can i do ?

googleadsapi...@google.com

unread,
Feb 15, 2019, 3:33:10 PM2/15/19
to AdWords API and Google Ads API Forum
Hello,

To clarify, are you looking for Google Ads Beta API? If you are using the Google Ads API Beta, the functionality is available from the 0.7 version on-words. Please refer to this release notes. Also, please check the supported library here. Unfortunately we don't have any direct example. However, you can use MutateCustomerManagerLink service and set the manager and client account id which you are looking to link using CustomerManagerLink object.

Also, please note that both the API client libraries can be used side by side and can send API calls to the AdWords API and the Google Ads API simultaneously. You could refer the slides in this blog post to know more information about the Beta API's RMF parity version release dates.


Thanks,
Milind, AdWords API Team
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~
Also find us on our blog and discussion group:
    http://googleadsdeveloper.blogspot.com/search/label/adwords_api
    https://developers.google.com/adwords/api/community/
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~

Was your question answered? Please rate your experience with us by taking a short survey.
If not -- reply to this email and tell us what else we can do to help.

Take Survey

On 02/15/19 09:00:20 ludovic...@gmail.com wrote:
Hi, the challenge is to only use the Google Ads API lib, i can't use the Google Adwords API.
So what can i do ?

--
--
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~
Also find us on our blog:
https://googleadsdeveloper.blogspot.com/
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~
 
You received this message because you are subscribed to the Google
Groups "AdWords API and Google Ads API Forum" group.
To post to this group, send email to adwor...@googlegroups.com
To unsubscribe from this group, send email to
adwords-api+unsubscribe@googlegroups.com
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 and Google Ads API Forum" group.
To unsubscribe from this group and stop receiving emails from it, send an email to adwords-api+unsubscribe@googlegroups.com.
Visit this group at https://groups.google.com/group/adwords-api.

ludovic...@gmail.com

unread,
Feb 18, 2019, 5:39:37 AM2/18/19
to AdWords API and Google Ads API Forum
Thanks that's what i'm looking for.

But i'm here :

$customerManagerLink = new CustomerManagerLink([
'manager_customer' => new StringValue(['value' => $resourceName]),
'manager_link_id' => new Int64Value(['value' => '??????']),
'status' => ManagerLinkStatusEnum\ManagerLinkStatus::ACTIVE
]);

$googleAds->getCustomerManagerLinkServiceClient()->mutateCustomerManagerLink($resourceName,$customerManagerLink);

Where can i find the Manager_link_id ??? Or create it ?

Cheers !

googleadsapi...@google.com

unread,
Feb 18, 2019, 10:19:18 PM2/18/19
to ludovic...@gmail.com, AdWords API and Google Ads API Forum
Hi,

My apologies for the delayed response. I am a colleague of Milind, allow me to provide support for your concern.

According to this link, the manager_link_id is a read only field and it is auto-generated when the link is mutated. You can only "GET" this field. This said, you can proceed on making your service call without specifying this field.

Regards,
Dannison
Google Ads API Team


=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~
Also find us on our blog and discussion group:
    http://googleadsdeveloper.blogspot.com/search/label/adwords_api
    https://developers.google.com/adwords/api/community/
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~

--
--
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~
Also find us on our blog:
https://googleadsdeveloper.blogspot.com/
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~
 
You received this message because you are subscribed to the Google
Groups "AdWords API and Google Ads API Forum" group.
To post to this group, send email to adwor...@googlegroups.com
To unsubscribe from this group, send email to
adwords-api+unsubscribe@googlegroups.com
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 and Google Ads API Forum" group.
To unsubscribe from this group and stop receiving emails from it, send an email to adwords-api+unsubscribe@googlegroups.com.
Visit this group at https://groups.google.com/group/adwords-api.

ludovic...@gmail.com

unread,
Feb 20, 2019, 2:38:12 AM2/20/19
to AdWords API and Google Ads API Forum
Hi, thanks a lot for your response.

But when i try without, nothing's happening !
My code is correct ?

Cheers !

googleadsapi...@google.com

unread,
Feb 20, 2019, 6:01:48 AM2/20/19
to AdWords API and Google Ads API Forum
Hi,

My apologies for the back and forth. Could you provide the complete code segment where you are implementing CustomerManagerLinkService? Also, could you further elaborate your observation when you mentioned that nothing happened? Could you provide any screenshots or logs so I could better investigate? You may provide them using the reply privately to author option.

Regards,
Dannison
Google Ads API Team


=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~
Also find us on our blog and discussion group:
    http://googleadsdeveloper.blogspot.com/search/label/adwords_api
    https://developers.google.com/adwords/api/community/
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~

Was your question answered? Please rate your experience with us by taking a short survey.
If not -- reply to this email and tell us what else we can do to help.

Take Survey

--
--
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~
Also find us on our blog:
https://googleadsdeveloper.blogspot.com/
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~
 
You received this message because you are subscribed to the Google
Groups "AdWords API and Google Ads API Forum" group.
To post to this group, send email to adwor...@googlegroups.com
To unsubscribe from this group, send email to
adwords-api+unsubscribe@googlegroups.com
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 and Google Ads API Forum" group.
To unsubscribe from this group and stop receiving emails from it, send an email to adwords-api+unsubscribe@googlegroups.com.
Visit this group at https://groups.google.com/group/adwords-api.

ludovic...@gmail.com

unread,
Mar 4, 2019, 3:27:34 AM3/4/19
to AdWords API and Google Ads API Forum
Hi, last time i send you a private message and i have no response yet !

This is my code and i don't know how to use it with Google Ads (not adwords) and i really need a solution for this one please !

$oAuth2Credential = (new OAuth2TokenBuilder())
->fromFile('google_ads_php.ini')
->withRefreshToken(self::getRefreshToken())
->build();

$googleAds = (new GoogleAdsClientBuilder())
->fromFile('google_ads_php.ini')
->withOAuth2Credential($oAuth2Credential)
->build();

$resourceName = Customer ID;

$customerManagerLinkOperation = new \Google\Ads\GoogleAds\V0\Services\CustomerManagerLinkOperation([
'manager_customer' => new StringValue(['value' => $googleAds->getLoginCustomerId()])
]);
$googleAds->getCustomerManagerLinkServiceClient()->mutateCustomerManagerLink($resourceName,$customerManagerLinkOperation);

googleadsapi...@google.com

unread,
Mar 5, 2019, 8:05:53 AM3/5/19
to ludovic...@gmail.com, AdWords API and Google Ads API Forum
Hello,

It looks like my last response went only to your private email address instead of getting posted publicly on the forum. I apologize for that. I will paste that response here:

To link two accounts using the Google Ads API, you first need to add a CustomerClientLink from the manager account, then accept the invitation by mutating the existing CustomerManagerLink from the client account. You cannot initiate the process from the client account.
If you're still having trouble with the PHP library once you attempt to follow this workflow, then you can file a bug for the PHP library specifically here: https://github.com/googleads/google-ads-php/issues

Regards,
Mike, Google Ads API Team

=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~
Also find us on our blog and discussion group:
    http://googleadsdeveloper.blogspot.com/search/label/adwords_api
    https://developers.google.com/adwords/api/community/
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~
--
--
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~
Also find us on our blog:
https://googleadsdeveloper.blogspot.com/
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~
 
You received this message because you are subscribed to the Google
Groups "AdWords API and Google Ads API Forum" group.
To post to this group, send email to adwor...@googlegroups.com
To unsubscribe from this group, send email to
adwords-api+unsubscribe@googlegroups.com
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 and Google Ads API Forum" group.
To unsubscribe from this group and stop receiving emails from it, send an email to adwords-api+unsubscribe@googlegroups.com.
Visit this group at https://groups.google.com/group/adwords-api.

ludovic...@gmail.com

unread,
Mar 5, 2019, 9:56:57 AM3/5/19
to AdWords API and Google Ads API Forum
I'm sorry but i don't understand ... Can you give me a sample code for that please ?

googleadsapi...@google.com

unread,
Mar 5, 2019, 10:09:10 AM3/5/19
to ludovic...@gmail.com, AdWords API and Google Ads API Forum
Hello,

Unfortunately, we don't have sample code for this operation available yet.

Essentially, the CustomerClientLink and CustomerManagerLink are two views of the same link. The CustomerClientLink is from the perspective of the manager account (customer), looking down at its client. The CustomerManagerLink is from the perspective of the client account (customer), looking up at its manager.

You need to create a CustomerClientLink (from the manager account) first, to initiate the link. This request will require that you send the manager CID to the API, and authenticate as a user who has access to the manager account.

Then you need to modify the same link, but in the form of a CustomerManagerLink (from the client account), to accept the invitation. This request will require that you send the client CID to the API, and authenticate as a user who has access to the client account.

These two operations in succession will successfully link the two accounts.

Regards,
Mike, Google Ads API Team

=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~
Also find us on our blog and discussion group:
    http://googleadsdeveloper.blogspot.com/search/label/adwords_api
    https://developers.google.com/adwords/api/community/
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~

On 03/05/19 09:56:56 ludovic...@gmail.com wrote:
I'm sorry but i don't understand ... Can you give me a sample code for that please ?

--
--
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~
Also find us on our blog:
https://googleadsdeveloper.blogspot.com/
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~
 
You received this message because you are subscribed to the Google
Groups "AdWords API and Google Ads API Forum" group.
To post to this group, send email to adwor...@googlegroups.com
To unsubscribe from this group, send email to
adwords-api+unsubscribe@googlegroups.com
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 and Google Ads API Forum" group.
To unsubscribe from this group and stop receiving emails from it, send an email to adwords-api+unsubscribe@googlegroups.com.
Visit this group at https://groups.google.com/group/adwords-api.

ludovic...@gmail.com

unread,
Mar 5, 2019, 10:35:21 AM3/5/19
to AdWords API and Google Ads API Forum
Ok, i think i got it thanks, but, how can i create : CustomerClientLink ?

Because when i try something like this isn't work !

$customerClientLink = new CustomerClientLink([
'client_customer' => new StringValue(['value' => $customerId])
]);

ludovic...@gmail.com

unread,
Mar 5, 2019, 10:36:12 AM3/5/19
to AdWords API and Google Ads API Forum
Sorry, i mean that's return me "null", even if i try with the MCID !

googleadsapi...@google.com

unread,
Mar 5, 2019, 9:43:07 PM3/5/19
to AdWords API and Google Ads API Forum
Hello Ludovic,

Thanks for your patience, I was able to expand the invitation to the client from my manager account using customerClientLinkService in Java. At this point I was only able to provide you the entire snippet in Java, apologies for that. While creating the customerCleintLink, you have to give the resource name of the client account you want to link and the status of the ManagerLinkStatus should be in PENDING status, if you are expanding the invitation. These two fields are mandatory. You could try the similar steps in PHP to perform mutate call to customerClientLinkService. Our team is aware that the code samples are not yet available for customerClientLinkService, we will update them soon. Please let me know if you have any further questions. 

Code Snippet Below in Java to expand the invitation to the client account from the manager account:

private void runExample(
       GoogleAdsClient googleAdsClient, long customerId) {
           try (CustomerClientLinkServiceClient customerClientLinkServiceClient = googleAdsClient.getCustomerClientLinkServiceClient()) 
          {
              //creatign resource name for customer
              String customerResourceName = ResourceNames.customer(123456789L);//the client account to which you are expanding the invitation. 

              //Creating customerClientLink object
             CustomerClientLink customerClientLink = CustomerClientLink.newBuilder()
             .setClientCustomer(StringValue.of(customerResourceName))
             .setStatus(ManagerLinkStatus.PENDING)
             .build();

              //creating operation for the mutate request
             CustomerClientLinkOperation operation = CustomerClientLinkOperation.newBuilder()
             .setCreate(customerClientLink)
             .build();

             // Send the operation in a mutate request.
             MutateCustomerClientLinkResponse response =
             customerClientLinkServiceClient.mutateCustomerClientLink("18xxxxxx17", operation);// Your manager account Id should be placed in the mutate call.
             // Print the resource name of each updated object. 
             System.out.println(response.getResult());
        }
 }

Regards,
Sai Teja, Google Ads API Team


=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~
Also find us on our blog and discussion group:
    http://googleadsdeveloper.blogspot.com/search/label/adwords_api
    https://developers.google.com/adwords/api/community/
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~

Was your question answered? Please rate your experience with us by taking a short survey.


If not -- reply to this email and tell us what else we can do to help.

Also find us on our blog and discussion group:
http://googleadsdeveloper.blogspot.com/search/label/adwords_api
https://developers.google.com/adwords/api/community/

ludovic...@gmail.com

unread,
Mar 6, 2019, 5:34:48 AM3/6/19
to AdWords API and Google Ads API Forum
Hi, how are you today ?

Thanks a lot for this code. I've tried to convert it to PHP but i have this error : 

Type: Google\Ads\GoogleAds\Lib\GoogleAdsException
Code: 13
Message: { "message": "Internal error encountered.", "code": 13, "status": "INTERNAL", "details": [ { "@type": "google.ads.googleads.v0.errors.googleadsfailure-bin", "data": "<Unknown Binary Data>" }, { "@type": "grpc-status-details-bin", "data": "<Unknown Binary Data>" }, { "@type": "request-id", "data": "D4xHl8hAr_Im37hVfMO6Ww" } ] }
File: C:\xampp\htdocs\ApiAdsWrapper\vendor\googleads\google-ads-php\src\Google\Ads\GoogleAds\Lib\GoogleAdsExceptionMiddleware.php
Line: 106


This is my code below :

$oAuth2Credential = (new OAuth2TokenBuilder())
->withClientId('CLIENT_ID')
->withClientSecret('CLIENT_SECRET')
->withRefreshToken('REFRESH_TOKEN')
->build();

$session = (new GoogleAdsClientBuilder())
->withDeveloperToken('DEVELOPER_TOKEN')
->withOAuth2Credential($oAuth2Credential)
->build();

$customerId = ResourceNames::forCustomer(8xxxxxxxx8);

$customerClientLinkServiceClient = $session->getCustomerClientLinkServiceClient();
$customerClientLink = new CustomerClientLink([
"client_customer" => new StringValue(['value' => $customerId]),
"status" => ManagerLinkStatus::PENDING
]);

$operation = new CustomerClientLinkOperation();
$operation->setCreate($customerClientLink);

$response = $customerClientLinkServiceClient->mutateCustomerClientLink("5xxxxxxx5", $operation);

ludovic...@gmail.com

unread,
Mar 6, 2019, 11:01:10 AM3/6/19
to AdWords API and Google Ads API Forum
Yes ! It's ok to generate the manager_link_id to ask one customer to link his account to the manager.
So now, i try to do the last action "accept the request".
I think i'm ok with my code, but when i try to do the change in cURL, they told me about this : "FIELD_MASK_MISSING".

This i my code below.

$customerManagerLinkServiceClient = $sessionCustomer->getCustomerManagerLinkServiceClient();
$customerManagerLink = new CustomerManagerLink([
"resource_name" => new StringValue(['value' => 'customers/1xxxxxxx1/customerClientLinks/1xxxxxx1_1xxxxxxx1']),
    "manager_customer" => new StringValue(['value' => 'customers/1xxxxxxx1']),
"manager_link_id" => new Int64Value(['value' => 1xxxxxxx1]),
"status" => 2
]);

$operationM = new CustomerManagerLinkOperation();
$operationM->setUpdate($customerManagerLink);

$responseM = $customerManagerLinkServiceClient->mutateCustomerManagerLink(2xxxxxxx2, [$operationM]);
$result = $responseM->getResults();

Cheers.

googleadsapi...@google.com

unread,
Mar 6, 2019, 3:21:44 PM3/6/19
to AdWords API and Google Ads API Forum
Hello Ludovic,

Glad the code worked to expand the invitation from manager to the client account. Now while accepting the invitation you have to mutate the clientCustomerLink with the credentials of client that is accepting the invitation from the manager account. After the setUpdte you have to add setUpdateMask method for the CleintCustomerLink that you want to update. This step is to mask the other non used fields of that entity. You could use the below code snippet after the line: $operationM->setUpdate($customerManagerLink);. Please let me know if you have any further questions.

code snippet in PHP:

$operationM->setUpdateMask(FieldMasks::allSetFieldsOf($customerManagerLink));

Regards,
Sai Teja, Google Ads API Team


=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~
Also find us on our blog and discussion group:
    http://googleadsdeveloper.blogspot.com/search/label/adwords_api
    https://developers.google.com/adwords/api/community/
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~

Kuba Dev

unread,
Mar 20, 2019, 7:13:19 AM3/20/19
to AdWords API and Google Ads API Forum
Hi Everyone !

I am facing the same problem with Ads Api.

I have created new account X under My manager account Y.
I would like to link random new user with ads account Z to my newly created account X.

But that way I should be able to manage account X as manager and also user will see this account X under his manager account Z.

is it possible?

Do somebody know the code in PHP for that operation?
Also what library should I use the AdWords Api or Ads Api ?

googleadsapi...@google.com

unread,
Mar 20, 2019, 3:37:42 PM3/20/19
to AdWords API and Google Ads API Forum
Hello Jakub,

For the AdWords API the client libraries are available here and for the Google Ads API the client libraries available here. Using AdWords API you can try the ManagedCustomerService and can refer the Linking accounts section of this guide for more information about the ManagedCustomerService.

If you are using the Google Ads API, you should use CustomerClientLinkService.MutateCustomerClientLink service. Below is the code sample to extend the invitation to the client account in Java. Since the examples are not available in out client libraries I can provide sample in Java only at this point of time. You can try the similar steps in PHP to extend the invitation. Likewise you have to update the ManagerLinkStatus to ACTIVE from the client account to accept the invitation.

Code Snippet Below in Java to extend the invitation to the client account from the manager account:


private void runExample(
GoogleAdsClient googleAdsClient, long customerId) {
try (CustomerClientLinkServiceClient customerClientLinkServiceClient = googleAdsClient.getCustomerClientLinkServiceClient()) 
{
      //Creating resource name for customer

      String customerResourceName = ResourceNames.customer(123456789L);//the client account to which you are expanding the invitation. 

      //Creating customerClientLink object
      CustomerClientLink customerClientLink = CustomerClientLink.newBuilder()
     .setClientCustomer(StringValue.of(customerResourceName))
     .setStatus(ManagerLinkStatus.PENDING)
     .build();

     //creating operation for the mutate request
     CustomerClientLinkOperation operation = CustomerClientLinkOperation.newBuilder()
     .setCreate(customerClientLink)
     .build();

     // Send the operation in a mutate request.
    MutateCustomerClientLinkResponse response =
    customerClientLinkServiceClient.mutateCustomerClientLink("18xxxxxx17", operation);// Your manager account Id should be placed in the mutate call.
    // Print the resource name of each updated object. 
    System.out.println(response.getResult());
    }
}

Please elaborate if you have any further questions.


Regards,
Sai Teja, Google Ads API Team


=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~
Also find us on our blog and discussion group:
    http://googleadsdeveloper.blogspot.com/search/label/adwords_api
    https://developers.google.com/adwords/api/community/
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~

Was your question answered? Please rate your experience with us by taking a short survey.
If not -- reply to this email and tell us what else we can do to help.

Take Survey

Also find us on our blog and discussion group:
http://googleadsdeveloper.blogspot.com/search/label/adwords_api
https://developers.google.com/adwords/api/community/

--
--
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~

Also find us on our blog:
https://googleadsdeveloper.blogspot.com/
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~
 
You received this message because you are subscribed to the Google
Groups "AdWords API and Google Ads API Forum" group.
To post to this group, send email to adwor...@googlegroups.com
To unsubscribe from this group, send email to
adwords-api+unsubscribe@googlegroups.com
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 and Google Ads API Forum" group.
To unsubscribe from this group and stop receiving emails from it, send an email to adwords-api+unsubscribe@googlegroups.com.
Visit this group at https://groups.google.com/group/adwords-api.

Van Vu

unread,
Mar 22, 2019, 6:44:09 AM3/22/19
to AdWords API and Google Ads API Forum
Hi there,
Thank you very much for the code snippet and the explanation above. I've been pulling my hair out in the last few days ...

So after the client accepts the Ads invitation, all done and dusted, my next step is linking the Merchant account with this client Ads account
I can update the Merchant to include the AdsId and see it go through --> OK

Question: how can I accept the invitation from Merchant by using Ads API (again, not Adwords), 
I already tried GetCustomerManagerLink but have no idea what to put in ResourceName

Please help

Kuba Dev

unread,
Mar 22, 2019, 7:58:02 AM3/22/19
to AdWords API and Google Ads API Forum
Hi,

Van Vu : You as upper post : "update the ManagerLinkStatus to ACTIVE from the client account"
Ofcourse client first need to login to your system and You need to keep his token to operate that.


Help ME : I am thinking about other case also:
Some time ago I registered an account in "AdEspr....".
And in this system after linking my ads account I got email with confimration that:
"My account XYZ has been connected with manager account AdEsp..... (XYZ)"

I am trying to reach the same case :
Client is about to login. then he select his account to operate in my system, and then system will connect his choosed account to My MMC account.

Is that case possible somehow?

googleadsapi...@google.com

unread,
Mar 22, 2019, 3:03:14 PM3/22/19
to AdWords API and Google Ads API Forum
Hello Bodom0911,

You could use the resource name as mentioned  resource_name: "customers/{customer_id}/customerClientLinks/{client_customer_id}~{manager_link_id}". You could also get the resource name of the customerClientLinks by using this query: "SELECT customer_client_link.resource_name FROM customer_client_link". Please let me know if you have any further questions.

@Kuba,

Does the client have multiple AdWords account and want to choose which account to connect to your manager account? If that is the case, you can change the clientCustomerId, So that the API requests will be made with the chosen account from the client. Same applies even while extending and accepting the invitation. If you question is different please elaborate and share any respective docs you are referring to? You could use reply privately to the author option while sharing the information requested.


Regards,
Sai Teja, Google Ads API Team



=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~
Also find us on our blog and discussion group:
    http://googleadsdeveloper.blogspot.com/search/label/adwords_api
    https://developers.google.com/adwords/api/community/
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~

Van Vu

unread,
Mar 25, 2019, 7:36:14 AM3/25/19
to AdWords API and Google Ads API Forum
Hello Sai Teja,
I use the code snippet below but there's nothing in response.Results

            var googleAdsService = client.GetService(Google.Ads.GoogleAds.Services.V0.GoogleAdsService);

            SearchGoogleAdsRequest request = new SearchGoogleAdsRequest()
            {
                PageSize = _pageSize,
                Query = @"SELECT customer_client_link.resource_name FROM customer_client_link",
                CustomerId = "xxxx"
            };

            foreach (SearchGoogleAdsResponse response in searchPagedResponse.AsRawResponses())
            {
                   Console.WriteLine(response.FieldMask.Paths);
                   foreach (GoogleAdsRow googleAdsRow in response.Results)
                   {
                       /// Nothing here
                   }
            }

But when I switch to Adwords API, it does have something

            // Get the CustomerService.
            var customerService = (Google.Api.Ads.AdWords.v201809.CustomerService)user.GetService(AdWordsService.v201809.CustomerService);

            // Create a selector that filters by service type.
            Selector selector = new Selector()
            {
                fields = new string[] { ServiceLink.Fields.ServiceType },
                predicates = new Predicate[] {
                    Predicate.Equals(ServiceLink.Fields.ServiceType, ServiceType.MERCHANT_CENTER.ToString())
                }
            };

            // Get the service links.
            var serviceLinks = customerService.getServiceLinks(selector);

            // Display the results.
            if (serviceLinks != null)
            {
                    /// Yes, there's something here
            }

Looks like I'll stick with Adwords API for now

What do you think?

googleadsapi...@google.com

unread,
Mar 25, 2019, 2:18:57 PM3/25/19
to AdWords API and Google Ads API Forum
Hello Van,

I am contacting our team internally regarding your issue. We will get back to you soon.

Regards,
SaI Teja, Google Ads API Team


=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~
Also find us on our blog and discussion group:
    http://googleadsdeveloper.blogspot.com/search/label/adwords_api
    https://developers.google.com/adwords/api/community/
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~

Непомнющий Александр

unread,
Apr 9, 2019, 6:06:19 PM4/9/19
to AdWords API and Google Ads API Forum
Hello Ludoviс,
can you me help? I'm trying to use your code to link Adwords accounts,  but in the code section with  
$customerClientLink = new CustomerClientLink([
"client_customer" => new StringValue(['value' => $customerId]),
"status"   => ManagerLinkStatus::PENDING
]);

I get 500 error from server.  I think the problem is with new CustomerClientLink.
Could you please show this section of your code?

require __DIR__ . '/vendor/autoload.php';

use GetOpt\GetOpt;
use Google\Auth\CredentialsLoader;
use Google\Auth\OAuth2;
use Psr\Http\Message\ServerRequestInterface;
use React\EventLoop\Factory;
use React\Http\Response;
use React\Http\Server;
use UnexpectedValueException;

use Google\Ads\GoogleAds\Examples\Utils\ArgumentNames;
use Google\Ads\GoogleAds\Examples\Utils\ArgumentParser;
use Google\Ads\GoogleAds\Lib\V1\GoogleAdsClient;
use Google\Ads\GoogleAds\Lib\V1\GoogleAdsClientBuilder;
use Google\Ads\GoogleAds\Lib\V1\GoogleAdsException;
use Google\Ads\GoogleAds\Lib\OAuth2TokenBuilder;
use Google\Ads\GoogleAds\V1\Errors\GoogleAdsError;
use Google\Ads\GoogleAds\V1\Services\GoogleAdsRow;
use Google\ApiCore\ApiException;
use Google\Ads\GoogleAds\V1\Resources\Customer;
use Google\Ads\GoogleAds\V1\Resources\CustomerManagerLink;



среда, 6 марта 2019 г., 17:01:10 UTC+1 пользователь ludovic...@gmail.com написал:

googleadsapi...@google.com

unread,
Apr 15, 2019, 1:29:56 AM4/15/19
to aleks....@gmail.com, AdWords API and Google Ads API Forum
Hi Aleks,

It appears as though the 500 error you're receiving is a bug in the API. The team is currently investigating it. I'll follow up here when there is a resolution and you can attempt your request again.

Apologies for the inconvenience!

Best,
Ben, Google Ads API Team


=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~
Also find us on our blog and discussion group:
--
--
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~

Also find us on our blog:
https://googleadsdeveloper.blogspot.com/
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~
 
You received this message because you are subscribed to the Google
Groups "AdWords API and Google Ads API Forum" group.
To post to this group, send email to adwor...@googlegroups.com
To unsubscribe from this group, send email to
adwords-api+unsubscribe@googlegroups.com
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 and Google Ads API Forum" group.
To unsubscribe from this group and stop receiving emails from it, send an email to adwords-api+unsubscribe@googlegroups.com.
Visit this group at https://groups.google.com/group/adwords-api.
Reply all
Reply to author
Forward
0 new messages