简体   繁体   中英

Need help to understand the new Google Ads API PHP LIB

I try to get the customer manager link from Google Ads API PHP Lib. But they except the Resource_name. What's that ?

$client->getCustomerManagerLinkServiceClient()->getCustomerManagerLink(resourceName)->getManagerLinkId();

They have no documentation in PHP for this new service. They have some examples but the one i need doesn't exist yet.

I try to merge an existing Ads/Adwords Customer to My Google Ads Manager (MCC). But i don't know what i'm suppose to do.

Thanks for help.

Cheers.

Someone can help me ?

This is my code if you want to see more. The challenge is to use only the Google Ads Api Library from this Github : https://github.com/googleads/google-ads-php

I don't want to use the Google Adwords API, juste Google Ads API.

$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);

I'm not familiar with the php library but with the python library you can use the GoogleAdsService together with google ads query to retrieve the data.

Example:

cutomer_id = '11111111111'
q = ('SELECT customer_manager_link.manager_customer, '
     'customer_manager_link.status '
     'FROM customer_manager_link'
result = ga_service.search(customer_id, q)

I think the same should be possible in php. Something like this:

 $googleAdsServiceClient = $googleAdsClient->getGoogleAdsServiceClient();
 $customerId = 11111111111
 $query = 'SELECT customer_manager_link.manager_customer, '
         .'customer_manager_link.status '
         .'FROM customer_manager_link'

 $response = $googleAdsServiceClient->search($customerId, $query);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM