Re: Example Code for Handling RateExceededError

2017-05-01 Thread Nick Harris
Thanks Vishal, followed your advice and am throwing a RateExceededError 
that replicates what a real one looks like using the following code:

$rateExceededError = new 
\Google\AdsApi\AdWords\v201702\cm\RateExceededError("", null, 
"","RateExceededError.RATE_EXCEEDED", "RateExceededError", 
"RATE_EXCEEDED","RequestsPerMinute", "ACCOUNT", 30);

$apiException = new \Google\AdsApi\AdWords\v201702\cm\ApiException(null, 
null, null, [$rateExceededError]);

// Now do something with $apiException



On Monday, May 1, 2017 at 9:08:26 AM UTC-7, Vishal Vinayak (Adwords API 
Team) wrote:
>
> Hi,
>
> You can also check out the procedure mentioned in this example 
> 
>  and 
> check if the error is an instance of RateExceededError and perform action 
> in your code accordingly. Although their is no direct way to simulate 
> RateExceededError in your API call, you can try to throw 
> 
>  the RateExceededError 
> manually in your code for that purpose. Also, an additional resource, 
> although available in Java programming language only,  is the RateLimiter 
> extension 
> 
>  which 
> can help handle rate limiting related issues by changing a few lines of 
> code. Please revert if you have additional questions or concerns. 
>
> Regards,
> Vishal, 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/c206316d-24f7-4c19-8d89-d085296f1fa9%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Example Code for Handling RateExceededError

2017-05-01 Thread 'Vishal Vinayak (Adwords API Team)' via AdWords API Forum
Hi,

You can also check out the procedure mentioned in this example 

 and 
check if the error is an instance of RateExceededError and perform action 
in your code accordingly. Although their is no direct way to simulate 
RateExceededError in your API call, you can try to throw 

 the RateExceededError 
manually in your code for that purpose. Also, an additional resource, 
although available in Java programming language only,  is the RateLimiter 
extension 

 which 
can help handle rate limiting related issues by changing a few lines of 
code. Please revert if you have additional questions or concerns. 

Regards,
Vishal, 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/25622e1b-fc64-448f-b0af-6d53301e3c87%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Example Code for Handling RateExceededError

2017-04-30 Thread Nick Harris
In process of answering my own question. Using a test account, I set up an 
infinite AWQL query loop that runs until it triggers a RATE_EXCEEDED error, 
like so:
while(2 > 1) {
try {
$page = CampaignService->query('SELECT id, .);
} catch (ApiException $apiException) {

foreach ($apiException->getErrors() as $error) {
$errorReason = $error->getReason();
if($errorReason == "RATE_EXCEEDED") {
$errArr = ([
'reason'=> $error->getReason(),
'rateName'  => $error->getRateName(),
'rateScope' => $error->getRateScope(),
'retryAfterSeconds' => $error->getRetryAfterSeconds()
]);
die(var_dump($errArr));
}
}
}
}

That fetches all the info there is about a RATE_EXCEEDED error. Next step 
is actually handle the retryAfterSeconds with further API calls...

On Friday, April 28, 2017 at 6:48:42 PM UTC-7, Nick Harris wrote:
>
> I want to be able to properly handle RateExceededError as described in 
> https://developers.google.com/adwords/api/docs/guides/rate-limits.
>
> Are there any code samples that show how to do this?
>
> Any way to simulate a RateExceededError so I can make sure my app handles 
> it correctly? Or should I just launch thousands of concurrent API calls to 
> generate a real error?
>

-- 
-- 
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~
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/76675418-e637-469f-bc68-02ef8258f4a1%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.