Re: Error Handling in new Adwords API v201708

2018-11-22 Thread 'Luis Xander Talag (AdWords API Team)' via AdWords API and Google Ads API Forum
Hi David,

Please note that Partial Failure 
 feature 
is not supported by TrafficEstimatorService 
.
 Also, 
based on this line [RateExceededError ], it seems the real concern here 
is regarding RateExceededError 
which
 
is encountered when too many requests were made to the API in a short 
period of time. As this is a different concern from the thread, please 
create a new one and we'll provide support on that one.

Thanks,
Luis
AdWords API Team

On Friday, November 23, 2018 at 1:10:28 PM UTC+8, David Moate wrote:
>
> Hello i have the same issue.
>
> try{
>   // Generate a refreshable OAuth2 credential for authentication.
>   $oAuth2Credential = (new OAuth2TokenBuilder())
>   ->fromFile()
>   ->build();
>   // Construct an API session configured from a properties file 
> and the OAuth2
>   // credentials above.
>   $session = (new AdWordsSessionBuilder())
>   ->fromFile()
>   ->withOAuth2Credential($oAuth2Credential)
>   ->build();
>
>   $result = $this->EstimateKeywordTraffic(new AdWordsServices(), 
> $session);
> }
> catch (ApiException $apiException) {
> print_r($apiException);
> }
>
> below my error:
> Fatal error: Uncaught Google\AdsApi\AdWords\v201802\cm\ApiException: 
> [RateExceededError  retryAfterSeconds=30>] in 
> /home/refleadfem/www/france/wp-content/plugins/adwords-plugin/library/vendor/googleads/googleads-php-lib/src/Google/AdsApi/Common/Util/Reflection.php:39
>  
> Stack trace: #0 
> /home/refleadfem/www/france/wp-content/plugins/adwords-plugin/library/vendor/googleads/googleads-php-lib/src/Google/AdsApi/Common/Util/Reflection.php(39):
>  
> ReflectionClass->newInstanceArgs(Array) #1 
> /home/refleadfem/www/france/wp-content/plugins/adwords-plugin/library/vendor/googleads/googleads-php-lib/src/Google/AdsApi/Common/AdsSoapClient.php(165):
>  
> Google\AdsApi\Common\Util\Reflection->createInstance('Google\\AdsApi\\A...', 
> Array) #2 
> /home/refleadfem/www/france/wp-content/plugins/adwords-plugin/library/vendor/googleads/googleads-php-lib/src/Google/AdsApi/Common/AdsSoapClient.php(130):
>  
> Google\AdsApi\Common\AdsSoapClient->parseApiExceptionFromSoapFault(Object(SoapFault))
>  
> #3 /home/refleadfem/ in 
> /home/refleadfem/www/france/wp-content/plugins/adwords-plugin/library/vendor/googleads/googleads-php-lib/src/Google/AdsApi/Common/Util/Reflection.php
>  
> on line 39
>
> i wrote use Google\AdsApi\AdWords\v201708\cm\ApiException;
> but it does not work.
>
> thank you for helping me.
>
>
>
> Le mardi 17 octobre 2017 13:10:06 UTC+2, MWA a écrit :
>>
>> I got it, I didn't added *use 
>> Google\AdsApi\AdWords\v201708\cm\ApiException;* now its working.
>>
>> Thanks.
>>
>> On Friday, October 13, 2017 at 5:57:07 PM UTC+5, MWA wrote:
>>>
>>> Hi,
>>> Can anyone tell me how to handle errors on new Adwords API v201708?
>>> Here is my code, I can not catch exception I've tried these 
>>> possibilities.
>>> My code is working fine but if there is an error I want to handle it.
>>>
>>> Code:
>>> $oAuth2Credential = (new OAuth2TokenBuilder())->fromFile()->build();
>>> 
>>> $session = (new 
>>> AdWordsSessionBuilder())->fromFile()->withOAuth2Credential($oAuth2Credential)->enablePartialFailure()->build();
>>>
>>> $adWordsServices=new AdWordsServices();
>>> 
>>> $managedCustomerService = $adWordsServices->get($session, 
>>> ManagedCustomerService::class);
>>>
>>> $link = new ManagedCustomerLink();
>>> $link->setManagerCustomerId($managerid);
>>> $link->setClientCustomerId($customerid);
>>> $link->setLinkStatus(LinkStatus::PENDING);
>>>
>>> $linkop = new LinkOperation();
>>> $linkop->setOperator(Operator::ADD);
>>> $linkop->setOperand($link);
>>>
>>> $operations = array($linkop);
>>> 
>>> try{
>>> $result = $managedCustomerService->mutateLink($operations);
>>> }catch(AdwordsApiException $e){
>>> print_r($e);
>>> print_r($result->getPartialFailureErrors());
>>> 
>>> }catch(Exception $e){
>>> print_r($e);
>>> print_r($result->getPartialFailureErrors());
>>> 
>>> }catch(ApiException $e){
>>> print_r($e);
>>> print_r($result->getPartialFailureErrors());
>>> 
>>> }
>>>
>>> Error:
>>>
>>> *Fatal error*: Uncaught exception 
>>> 'Google\AdsApi\AdWords\v201708\cm\ApiException' with message 
>>> '[ManagedCustomerServiceError.ALREADY_INVITED_BY_THIS_MANAGER @ 
>>> operations[0]]' in 
>>> /var/www/adwords_api/vendor/googleads/googleads-php-lib/src/Google/AdsApi/Common/Util/Reflection.php:39
>>>  
>>> Stack trace: #0 
>>> 

Re: Error Handling in new Adwords API v201708

2018-11-22 Thread David Moate
Hello i have the same issue.

try{
  // Generate a refreshable OAuth2 credential for authentication.
  $oAuth2Credential = (new OAuth2TokenBuilder())
  ->fromFile()
  ->build();
  // Construct an API session configured from a properties file and 
the OAuth2
  // credentials above.
  $session = (new AdWordsSessionBuilder())
  ->fromFile()
  ->withOAuth2Credential($oAuth2Credential)
  ->build();

  $result = $this->EstimateKeywordTraffic(new AdWordsServices(), 
$session);
}
catch (ApiException $apiException) {
print_r($apiException);
}

below my error:
Fatal error: Uncaught Google\AdsApi\AdWords\v201802\cm\ApiException: 
[RateExceededError ] in 
/home/refleadfem/www/france/wp-content/plugins/adwords-plugin/library/vendor/googleads/googleads-php-lib/src/Google/AdsApi/Common/Util/Reflection.php:39
 
Stack trace: #0 
/home/refleadfem/www/france/wp-content/plugins/adwords-plugin/library/vendor/googleads/googleads-php-lib/src/Google/AdsApi/Common/Util/Reflection.php(39):
 
ReflectionClass->newInstanceArgs(Array) #1 
/home/refleadfem/www/france/wp-content/plugins/adwords-plugin/library/vendor/googleads/googleads-php-lib/src/Google/AdsApi/Common/AdsSoapClient.php(165):
 
Google\AdsApi\Common\Util\Reflection->createInstance('Google\\AdsApi\\A...', 
Array) #2 
/home/refleadfem/www/france/wp-content/plugins/adwords-plugin/library/vendor/googleads/googleads-php-lib/src/Google/AdsApi/Common/AdsSoapClient.php(130):
 
Google\AdsApi\Common\AdsSoapClient->parseApiExceptionFromSoapFault(Object(SoapFault))
 
#3 /home/refleadfem/ in 
/home/refleadfem/www/france/wp-content/plugins/adwords-plugin/library/vendor/googleads/googleads-php-lib/src/Google/AdsApi/Common/Util/Reflection.php
 
on line 39

i wrote use Google\AdsApi\AdWords\v201708\cm\ApiException;
but it does not work.

thank you for helping me.



Le mardi 17 octobre 2017 13:10:06 UTC+2, MWA a écrit :
>
> I got it, I didn't added *use 
> Google\AdsApi\AdWords\v201708\cm\ApiException;* now its working.
>
> Thanks.
>
> On Friday, October 13, 2017 at 5:57:07 PM UTC+5, MWA wrote:
>>
>> Hi,
>> Can anyone tell me how to handle errors on new Adwords API v201708?
>> Here is my code, I can not catch exception I've tried these possibilities.
>> My code is working fine but if there is an error I want to handle it.
>>
>> Code:
>> $oAuth2Credential = (new OAuth2TokenBuilder())->fromFile()->build();
>> 
>> $session = (new 
>> AdWordsSessionBuilder())->fromFile()->withOAuth2Credential($oAuth2Credential)->enablePartialFailure()->build();
>>
>> $adWordsServices=new AdWordsServices();
>> 
>> $managedCustomerService = $adWordsServices->get($session, 
>> ManagedCustomerService::class);
>>
>> $link = new ManagedCustomerLink();
>> $link->setManagerCustomerId($managerid);
>> $link->setClientCustomerId($customerid);
>> $link->setLinkStatus(LinkStatus::PENDING);
>>
>> $linkop = new LinkOperation();
>> $linkop->setOperator(Operator::ADD);
>> $linkop->setOperand($link);
>>
>> $operations = array($linkop);
>> 
>> try{
>> $result = $managedCustomerService->mutateLink($operations);
>> }catch(AdwordsApiException $e){
>> print_r($e);
>> print_r($result->getPartialFailureErrors());
>> 
>> }catch(Exception $e){
>> print_r($e);
>> print_r($result->getPartialFailureErrors());
>> 
>> }catch(ApiException $e){
>> print_r($e);
>> print_r($result->getPartialFailureErrors());
>> 
>> }
>>
>> Error:
>>
>> *Fatal error*: Uncaught exception 
>> 'Google\AdsApi\AdWords\v201708\cm\ApiException' with message 
>> '[ManagedCustomerServiceError.ALREADY_INVITED_BY_THIS_MANAGER @ 
>> operations[0]]' in 
>> /var/www/adwords_api/vendor/googleads/googleads-php-lib/src/Google/AdsApi/Common/Util/Reflection.php:39
>>  
>> Stack trace: #0 
>> /var/www/adwords_api/vendor/googleads/googleads-php-lib/src/Google/AdsApi/Common/Util/Reflection.php(39):
>>  
>> ReflectionClass->newInstanceArgs(Array) #1 
>> /var/www/adwords_api/vendor/googleads/googleads-php-lib/src/Google/AdsApi/Common/AdsSoapClient.php(165):
>>  
>> Google\AdsApi\Common\Util\Reflection->createInstance('Google\AdsApi\A...', 
>> '[ManagedCustome...') #2 
>> /var/www/adwords_api/vendor/googleads/googleads-php-lib/src/Google/AdsApi/Common/AdsSoapClient.php(130):
>>  
>> Google\AdsApi\Common\AdsSoapClient->parseApiExceptionFromSoapFault(Object(SoapFault))
>>  
>> #3 
>> /var/www/adwords_api/vendor/googleads/googleads-php-lib/src/Google/AdsApi/AdWords/v201708/mcm/ManagedCustomerService.php(185):
>>  
>> Google\AdsApi\Common\AdsSoapClient->__soapCall('mutateLink', Array in 
>> */var/www/adwords_api/vendor/googleads/googleads-php-lib/src/Google/AdsApi/Common/Util/Reflection.php*
>>  
>> on line *39*
>>
>>
>>
>> Thanks.
>>
>

-- 
-- 

Re: Error Handling in new Adwords API v201708

2017-10-17 Thread MWA
I got it, I didn't added *use 
Google\AdsApi\AdWords\v201708\cm\ApiException;* now its working.

Thanks.

On Friday, October 13, 2017 at 5:57:07 PM UTC+5, MWA wrote:
>
> Hi,
> Can anyone tell me how to handle errors on new Adwords API v201708?
> Here is my code, I can not catch exception I've tried these possibilities.
> My code is working fine but if there is an error I want to handle it.
>
> Code:
> $oAuth2Credential = (new OAuth2TokenBuilder())->fromFile()->build();
> 
> $session = (new 
> AdWordsSessionBuilder())->fromFile()->withOAuth2Credential($oAuth2Credential)->enablePartialFailure()->build();
>
> $adWordsServices=new AdWordsServices();
> 
> $managedCustomerService = $adWordsServices->get($session, 
> ManagedCustomerService::class);
>
> $link = new ManagedCustomerLink();
> $link->setManagerCustomerId($managerid);
> $link->setClientCustomerId($customerid);
> $link->setLinkStatus(LinkStatus::PENDING);
>
> $linkop = new LinkOperation();
> $linkop->setOperator(Operator::ADD);
> $linkop->setOperand($link);
>
> $operations = array($linkop);
> 
> try{
> $result = $managedCustomerService->mutateLink($operations);
> }catch(AdwordsApiException $e){
> print_r($e);
> print_r($result->getPartialFailureErrors());
> 
> }catch(Exception $e){
> print_r($e);
> print_r($result->getPartialFailureErrors());
> 
> }catch(ApiException $e){
> print_r($e);
> print_r($result->getPartialFailureErrors());
> 
> }
>
> Error:
>
> *Fatal error*: Uncaught exception 
> 'Google\AdsApi\AdWords\v201708\cm\ApiException' with message 
> '[ManagedCustomerServiceError.ALREADY_INVITED_BY_THIS_MANAGER @ 
> operations[0]]' in 
> /var/www/adwords_api/vendor/googleads/googleads-php-lib/src/Google/AdsApi/Common/Util/Reflection.php:39
>  
> Stack trace: #0 
> /var/www/adwords_api/vendor/googleads/googleads-php-lib/src/Google/AdsApi/Common/Util/Reflection.php(39):
>  
> ReflectionClass->newInstanceArgs(Array) #1 
> /var/www/adwords_api/vendor/googleads/googleads-php-lib/src/Google/AdsApi/Common/AdsSoapClient.php(165):
>  
> Google\AdsApi\Common\Util\Reflection->createInstance('Google\AdsApi\A...', 
> '[ManagedCustome...') #2 
> /var/www/adwords_api/vendor/googleads/googleads-php-lib/src/Google/AdsApi/Common/AdsSoapClient.php(130):
>  
> Google\AdsApi\Common\AdsSoapClient->parseApiExceptionFromSoapFault(Object(SoapFault))
>  
> #3 
> /var/www/adwords_api/vendor/googleads/googleads-php-lib/src/Google/AdsApi/AdWords/v201708/mcm/ManagedCustomerService.php(185):
>  
> Google\AdsApi\Common\AdsSoapClient->__soapCall('mutateLink', Array in 
> */var/www/adwords_api/vendor/googleads/googleads-php-lib/src/Google/AdsApi/Common/Util/Reflection.php*
>  
> on line *39*
>
>
>
> Thanks.
>

-- 
-- 
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~
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 adwords-api@googlegroups.com
To unsubscribe from this group, send email to
adwords-api+unsubscr...@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 Forum" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to adwords-api+unsubscr...@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/bbbe4551-5a83-4ff6-abbc-26a84a2ff10b%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Error Handling in new Adwords API v201708

2017-10-17 Thread MWA
If I apply try catch on get service nothing changes.

 try{
$page = $campaignService->get($selector);
}
catch (ApiException $apiException) {
print_r($apiException);
}


-- 
-- 
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~
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 adwords-api@googlegroups.com
To unsubscribe from this group, send email to
adwords-api+unsubscr...@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 Forum" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to adwords-api+unsubscr...@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/fe2552ee-d480-43fd-8a98-2a04433d8073%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Error Handling in new Adwords API v201708

2017-10-17 Thread MWA
I've imported namespaces correctly. If I provide customerid which I have 
currently access, it works fine, but when i try to access data of my 
ex-client (which of course I don't have access) the code breaks and the 
whole crons stops. I want to catch the exception so that I can download 
clients data which I have currently access and of course notify me that 
someone has left so I can stop that client's data downloading.

namespace Google\AdsApi\Examples\AdWords\v201708\BasicOperations;
ini_set("display_errors",1);
require __DIR__ . '/vendor/autoload.php';
use Google\AdsApi\AdWords\AdWordsServices;
use Google\AdsApi\AdWords\AdWordsSession;
use Google\AdsApi\AdWords\AdWordsSessionBuilder;
use Google\AdsApi\AdWords\v201708\cm\CampaignService;
use Google\AdsApi\AdWords\v201708\cm\OrderBy;
use Google\AdsApi\AdWords\v201708\cm\Paging;
use Google\AdsApi\AdWords\v201708\cm\Predicate;
use Google\AdsApi\AdWords\v201708\cm\PredicateOperator;
use Google\AdsApi\AdWords\v201708\cm\Selector;
use Google\AdsApi\AdWords\v201708\cm\SortOrder;
use Google\AdsApi\Common\OAuth2TokenBuilder;


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

$error=false;
try{
$session = (new 
AdWordsSessionBuilder())->fromFile()->withOAuth2Credential($oAuth2Credential)->withClientCustomerId($customerid)->enablePartialFailure()->build();
}
catch(ApiException $apiException) {
print_r($apiException);
}

$adWordsServices=new AdWordsServices();
$campaignService = $adWordsServices->get($session, 
CampaignService::class);

$selector = new Selector();
$Fields = array('Id', 'StartDate', 'EndDate', 'Name', 'Amount', 
'DeliveryMethod', 'ServingStatus', 'FrequencyCapMaxImpressions', 
'AdServingOptimizationStatus', 'TimeUnit', 'Level', 'Status', 
'BiddingStrategyType');
$selector->setFields($Fields);
$selector->setOrdering([new OrderBy('Name', SortOrder::ASCENDING)]);
$selector->setPaging(new Paging(0, 5000));
$totalNumEntries = 0;
$icount=0;

$selector->setPredicates([new Predicate('Status', 
PredicateOperator::IN, ['ENABLED', 'PAUSED', 'REMOVED'])]);

$page = $campaignService->get($selector);






On Friday, October 13, 2017 at 5:57:07 PM UTC+5, MWA wrote:
>
> Hi,
> Can anyone tell me how to handle errors on new Adwords API v201708?
> Here is my code, I can not catch exception I've tried these possibilities.
> My code is working fine but if there is an error I want to handle it.
>
> Code:
> $oAuth2Credential = (new OAuth2TokenBuilder())->fromFile()->build();
> 
> $session = (new 
> AdWordsSessionBuilder())->fromFile()->withOAuth2Credential($oAuth2Credential)->enablePartialFailure()->build();
>
> $adWordsServices=new AdWordsServices();
> 
> $managedCustomerService = $adWordsServices->get($session, 
> ManagedCustomerService::class);
>
> $link = new ManagedCustomerLink();
> $link->setManagerCustomerId($managerid);
> $link->setClientCustomerId($customerid);
> $link->setLinkStatus(LinkStatus::PENDING);
>
> $linkop = new LinkOperation();
> $linkop->setOperator(Operator::ADD);
> $linkop->setOperand($link);
>
> $operations = array($linkop);
> 
> try{
> $result = $managedCustomerService->mutateLink($operations);
> }catch(AdwordsApiException $e){
> print_r($e);
> print_r($result->getPartialFailureErrors());
> 
> }catch(Exception $e){
> print_r($e);
> print_r($result->getPartialFailureErrors());
> 
> }catch(ApiException $e){
> print_r($e);
> print_r($result->getPartialFailureErrors());
> 
> }
>
> Error:
>
> *Fatal error*: Uncaught exception 
> 'Google\AdsApi\AdWords\v201708\cm\ApiException' with message 
> '[ManagedCustomerServiceError.ALREADY_INVITED_BY_THIS_MANAGER @ 
> operations[0]]' in 
> /var/www/adwords_api/vendor/googleads/googleads-php-lib/src/Google/AdsApi/Common/Util/Reflection.php:39
>  
> Stack trace: #0 
> /var/www/adwords_api/vendor/googleads/googleads-php-lib/src/Google/AdsApi/Common/Util/Reflection.php(39):
>  
> ReflectionClass->newInstanceArgs(Array) #1 
> /var/www/adwords_api/vendor/googleads/googleads-php-lib/src/Google/AdsApi/Common/AdsSoapClient.php(165):
>  
> Google\AdsApi\Common\Util\Reflection->createInstance('Google\AdsApi\A...', 
> '[ManagedCustome...') #2 
> /var/www/adwords_api/vendor/googleads/googleads-php-lib/src/Google/AdsApi/Common/AdsSoapClient.php(130):
>  
> Google\AdsApi\Common\AdsSoapClient->parseApiExceptionFromSoapFault(Object(SoapFault))
>  
> #3 
> /var/www/adwords_api/vendor/googleads/googleads-php-lib/src/Google/AdsApi/AdWords/v201708/mcm/ManagedCustomerService.php(185):
>  
> Google\AdsApi\Common\AdsSoapClient->__soapCall('mutateLink', Array in 
> */var/www/adwords_api/vendor/googleads/googleads-php-lib/src/Google/AdsApi/Common/Util/Reflection.php*
>  
> on line *39*
>
>
>
> Thanks.
>

-- 
-- 
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~
Also 

Re: Error Handling in new Adwords API v201708

2017-10-16 Thread 'Jude Amagoh' via AdWords API Forum
Hi,

Could you check that you have imported the namespaces correctly as shown 
here 
?
 
Please note that ManagedCustomerService doesn't support partial failures. 
The partial failure feature is only supported in the list of API services 
provided here 
.
 
When partialFailure is set to true, you need to handle these 
partialFailures in the *try* block as shown here 
.
 
You can catch other API exceptions in the *catch* block as shown here 

.

Regards,
Jude, AdWords API Team

-- 
-- 
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~
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 adwords-api@googlegroups.com
To unsubscribe from this group, send email to
adwords-api+unsubscr...@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 Forum" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to adwords-api+unsubscr...@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/cc2d684f-9b1b-4679-98d5-97e68cbda72f%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Error Handling in new Adwords API v201708

2017-10-16 Thread MWA
Hi Jude,
Thank you for replying.

But the problem is we download our client's data and sometimes our client 
revoke access and we haven't fully updated that into our system and while 
we download data like this.

// Generate a refreshable OAuth2 credential for authentication.
$oAuth2Credential = (new OAuth2TokenBuilder())->fromFile()->build();
// Construct an API session configured from a properties file and 
the OAuth2 credentials above.
$session = (new 
AdWordsSessionBuilder())->fromFile()->withOAuth2Credential($oAuth2Credential)->withClientCustomerId($customerid)->build();

$adWordsServices=new AdWordsServices();


The error occurs, 

*Fatal error*:  Uncaught exception 
'Google\AdsApi\AdWords\v201708\cm\ApiException' with message 
'[AuthorizationError.USER_PERMISSION_DENIED @ ; trigger:'']'
 in 
/var/www/adwords_api/vendor/googleads/googleads-php-lib/src/Google/AdsApi/
Common/Util/Reflection.php:39
Stack trace:
#0 
/var/www/adwords_api/vendor/googleads/googleads-php-lib/src/Google/AdsApi/
Common/Util/Reflection.php(39):
 ReflectionClass->newInstanceArgs(Array)
#1 
/var/www/adwords_api/vendor/googleads/googleads-php-lib/src/Google/AdsApi/
Common/AdsSoapClient.php(165):
 
Google\AdsApi\Common\Util\Reflection->createInstance('Google\AdsApi\A...',
 '[AuthorizationE...')
#2 
/var/www/adwords_api/vendor/googleads/googleads-php-lib/src/Google/AdsApi/
Common/AdsSoapClient.php(130):
 
Google\AdsApi\Common\AdsSoapClient->parseApiExceptionFromSoapFault(Object(
SoapFault))
#3 
/var/www/adwords_api/vendor/googleads/googleads-php-lib/src/Google/AdsApi/
AdWords/v201708/cm/CampaignService.php(158):
 Google\AdsApi\Common\AdsSoapClient->__soapCall('get', Array)
#4 /var/www/adwords_api/Ge in 
*/var/www/adwords_api/vendor/googleads/googleads-php-lib/src/Google/AdsApi/Common/Util/Reflection.php*
 
on line *39*


Can we catch this error somehow, so that other clients don't get effected?

Thanks.

On Friday, October 13, 2017 at 5:57:07 PM UTC+5, MWA wrote:
>
> Hi,
> Can anyone tell me how to handle errors on new Adwords API v201708?
> Here is my code, I can not catch exception I've tried these possibilities.
> My code is working fine but if there is an error I want to handle it.
>
> Code:
> $oAuth2Credential = (new OAuth2TokenBuilder())->fromFile()->build();
> 
> $session = (new 
> AdWordsSessionBuilder())->fromFile()->withOAuth2Credential($oAuth2Credential)->enablePartialFailure()->build();
>
> $adWordsServices=new AdWordsServices();
> 
> $managedCustomerService = $adWordsServices->get($session, 
> ManagedCustomerService::class);
>
> $link = new ManagedCustomerLink();
> $link->setManagerCustomerId($managerid);
> $link->setClientCustomerId($customerid);
> $link->setLinkStatus(LinkStatus::PENDING);
>
> $linkop = new LinkOperation();
> $linkop->setOperator(Operator::ADD);
> $linkop->setOperand($link);
>
> $operations = array($linkop);
> 
> try{
> $result = $managedCustomerService->mutateLink($operations);
> }catch(AdwordsApiException $e){
> print_r($e);
> print_r($result->getPartialFailureErrors());
> 
> }catch(Exception $e){
> print_r($e);
> print_r($result->getPartialFailureErrors());
> 
> }catch(ApiException $e){
> print_r($e);
> print_r($result->getPartialFailureErrors());
> 
> }
>
> Error:
>
> *Fatal error*: Uncaught exception 
> 'Google\AdsApi\AdWords\v201708\cm\ApiException' with message 
> '[ManagedCustomerServiceError.ALREADY_INVITED_BY_THIS_MANAGER @ 
> operations[0]]' in 
> /var/www/adwords_api/vendor/googleads/googleads-php-lib/src/Google/AdsApi/Common/Util/Reflection.php:39
>  
> Stack trace: #0 
> /var/www/adwords_api/vendor/googleads/googleads-php-lib/src/Google/AdsApi/Common/Util/Reflection.php(39):
>  
> ReflectionClass->newInstanceArgs(Array) #1 
> /var/www/adwords_api/vendor/googleads/googleads-php-lib/src/Google/AdsApi/Common/AdsSoapClient.php(165):
>  
> Google\AdsApi\Common\Util\Reflection->createInstance('Google\AdsApi\A...', 
> '[ManagedCustome...') #2 
> /var/www/adwords_api/vendor/googleads/googleads-php-lib/src/Google/AdsApi/Common/AdsSoapClient.php(130):
>  
> Google\AdsApi\Common\AdsSoapClient->parseApiExceptionFromSoapFault(Object(SoapFault))
>  
> #3 
> /var/www/adwords_api/vendor/googleads/googleads-php-lib/src/Google/AdsApi/AdWords/v201708/mcm/ManagedCustomerService.php(185):
>  
> Google\AdsApi\Common\AdsSoapClient->__soapCall('mutateLink', Array in 
> */var/www/adwords_api/vendor/googleads/googleads-php-lib/src/Google/AdsApi/Common/Util/Reflection.php*
>  
> on line *39*
>
>
>
> Thanks.
>

-- 
-- 
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~
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 

Re: Error Handling in new Adwords API v201708

2017-10-13 Thread 'Jude Amagoh' via AdWords API Forum
Hi,

The AdWords API Client Library 
 provides 
examples of common error handling functions when detailing with partial 
failures 
. 
You can find a code example in PHP demonstrating how to handle partial 
failures here 

 . Let 
me know if you run into any issues. 

Best Regards,
Jude, Adwords API Team

-- 
-- 
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~
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 adwords-api@googlegroups.com
To unsubscribe from this group, send email to
adwords-api+unsubscr...@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 Forum" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to adwords-api+unsubscr...@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/b2d41104-f154-4fb9-b3f0-859b45b3bdad%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.