I am using the Google translate API V2 very intensely and after about 2000 requests I start getting this in the returning JSON:
Array
(
[error] => Array
(
[errors] => Array
(
[0] => Array
(
[domain] => usageLimits
[reason] => userRateLimitExceeded
[message] => User Rate Limit Exceeded
)
)
[code] => 403
[message] => User Rate Limit Exceeded
)
)
Any idea what the rate limit is? and do you have a smart way of regulating the requests rate?
I finally found out so I will answer my own question.
The rate limit for the API can be set at the admin panel for your API's (https://code.google.com/apis/console) under the quotas section in the left hand menu.
I did not find a full documentation of the possible errors that can be returned by an API.
HTTP status 403 is returned whenever the quota is exceeded.
Remark
I've been playing around with very low quotas to test whether this really works as expected. It seems that the quota settings are not applied immediately, since it took some time (~10-20 minutes) until the API finally stopped working (and returned the mentioned error code).
Related
How do I make sure that customer purchases tracked using the Measurement Protocol retain their association with the original Google Analytics session?
Detail:
When my site stopped registering customer purchases in Google Analytics (a whole other problem) I moved over to using the Measurement Protocol to send transactions to GA. This works *almost* perfectly - purchases appear in Google Analytics (I'm using Enhanced Ecommerce tracking) reliably.
However, almost all transactions are attributed to the 'direct' channel. Only a very few - perhaps 10% - retain their association with the campaign or channel that brought the customer to my site.
Here is an example of what I send using the Measurement protocol, from the 'thank you' page after a customer has made an order.
Array
(
[v] => 1
[tid] => UA-1234567-1
[cid] => 424729672.1597913127
[t] => pageview
[dh] => www.mysitename.co.uk
[dp] => /complete.php
[dt] => complete
[ti] => 540892
[ta] => Company Name
[tr] => 162.50
[tt] => 32.50
[ts] => 0
[col] => UNKNOWN
[pa] => purchase
[ua] => Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/84.0.4147.125 Safari/537.36
[geoid] => GB
[uip] => 12.34.56.78
[cu] => GBP
[uid] => 798f77110ea1667e9fdfc27ce83471042f01884c
[pr1id] => 15154737723
[pr1nm] => Product name in product colour
[pr1br] => Brand name
[pr1ca] => Product Category name
[pr1pr] => 195.00
[pr1qt] => 1
[pr1va] => Brown & tan
[z] => 1640
)
As you can see cid and uid are present. The cid is extracted from the _ga cookie. The uid (added yesterday) is what I have previously assigned to the customer earlier in their checkout process, but adding this has not improved the attribution situation. (Should I wait 24-48 hours to check?)
All payment processors, including 3D Secure domains, have been added to my Referral Exclusions list. My site is split between www.mysitename.co.uk (browsing) and secure.mysitename.co.uk (buying), but both of these domains are in the exclusion list as well, so I don't think it's cross domain issues, although the symptoms are similar.
utm_nooverride=1 has been added to the 'success' URLs supplied to payment processors, also, to no avail.
The site runs on a LAMP stack, apache 2.4, php 5.6. Server upgrade is due soon.
There are no other issues with Google Analytics. As well as Universal Analytics there is also some Google Tag Manager usage on the site.
If two hits share the Google Analytics Property ID and the Client ID (cid), and they take place within the session timeout (30 minutes) and on the same side of midnight, and they share all the campaign parameters, then they will be contained in the same session.
I've noticed that you're not sending the queue time parameter (qt) in the request. Are you sending the hits immediately after the phone call? Does this action occur moments later?
I believe that even if you send the hit immediately after the phone call, Google Analytics could process the hit with some delay. The queue time parameter is important to specify the exact time of the action.
I'm sending Enhanced Ecommerce purchases through the measurement protocol as well and I send the queue time parameter with the difference in seconds between the real timestamp of the purchase and the timestamp of the moment that my hit is being sent.
If you already solved this question, let us know.
You can read about sending a hit to a moment in the past in this excellent article https://www.simoahava.com/analytics/send-hits-past-google-analytics/.
I am using API V1 API, I am able to post on feeds but unable to fetch my feeds.
I am using following laravel package : https://github.com/artesaos/laravel-linkedin
To fetch feeds:
$posts = LinkedIn::get('v2/activityFeeds?q=networkShares&count=2');
I am getting following error:
array:3 [▼
"serviceErrorCode" => 100
"message" => "Not enough permissions to access: GET-networkShares /activityFeeds"
"status" => 403
]
In App setting there is no such to give permissions. Below is the screenshot: https://www.awesomescreenshot.com/image/3644392/6f92b88a7d73be3545126b88d49234c6
for the use of the V2 you need to require a partnership with linkedin.
https://developer.linkedin.com/partner-programs
check the box of the permissions you need (you have to conduct some research into what you need).
PS: this can take up to 1+ months before the partnership is accepted
I am trying to connect contact form 7 with velocify using the Plugin: "Forms: 3rd-Party Integration". Lead created in velocify but no field data import. I have mapped the fields correctly as per the instructions given. Here is the debug message:
SUBMISSION
Array
(
[timeout] => 60
[body] =>
)
RAW RESPONSE
Array
(
[reason] => Could not locate success clause within response
[safe_message] => Success Clause not found
[clause] => done
[response] => <?xml version="1.0" encoding="UTF-8"?><ImportResults><ImportResult refId="" leadId="0" result="Failure" message="No input data was found" /></ImportResults>
)
Please help me out.
This is a strange place to ask this question, as opposed to:
WP stack exchange site
the plugin support forum
the plugin Github issue tracker
That said, as the plugin author I suggest you read the support forum's sticky post: https://wordpress.org/support/topic/its-not-sending-data-help-read-this-first/
Specifically in your case, the debug email tells you the two problems:
You've configured the service to expect the word 'done' in the response, and it's not finding it
It's not finding it because, as the response indicates 'No input data was found' confirming the empty body of the submission.
The second issue (which is the real problem) is probably that you're not mapping it correctly. But without the full debug (or at least the service configuration section of it) I can't tell you why. Look at the "Post (Form)" section to see what's available to map. If you have done it all correctly it may be a compatibility issue -- make sure you're using the latest versions of all relevant plugins, try turning off other unrelated plugins to see if there's some kind of conflict, and finally if you have FTP access turn on WP_DEBUG mode and check the log file.
I am trying to use the Marketo activities.json API endpoint, and I am getting a timeout everytime I try. I have set the cURL timeout to 25 seconds and I am using a valid nextPageToken parameter to filter the results. The timeframe is yesterday and today.
When I try other endpoints (lists.json, activities/pagingtoken.json, leads.json, lists.json, and stats/usage/last7days.json) I get a response and my request does not timeout.
Here is the request I am making to activities.json:
method: "GET"
url: "https://[marketo-id].mktorest.com/rest/v1/activities.json"
parameters: Array
(
[nextPageToken] => [paging-token]
[listId] => [list-id]
[activityTypeIds] => 24
[access_token] => [access-token]
)
Why am I getting a timeout just for the activities.json endpoint? Is this API endpoint broken or down?
The global timeout for Marketo's REST API is 30 seconds, can you first try adjusting your local timeout to match this? If you remove list ID from from the call what happens?
I've desperately tried to figure this out on my own, and did not want to come to SO with this question, but I'm at my wits end (no thanks to the api / oauth docs).
I'm working in PHP and I'm trying to avoid using the Google_Client and AnalyticsService classes, by using REST on the analytics.data.ga.get method.
STEP #1: Create an API Project for a Web Application
I go to the api console and create a project with analytics services and get an OAuth Client ID and Secret.
I'm under the impression that I can create a Client ID for an Installed Application or a Web Application because I'm doing the initial token handshaking manually. Please correct me if I'm wrong.
I create a Client ID for web applications and get my Client ID xxxxxxxxxxxxxx.apps.googleusercontent.com, Client secret yyyyyyyyyyyyyyy, and my Redirect URI is http://localhost:9002
STEP #2: Request initial API access
I enter this link; https://accounts.google.com/o/oauth2/auth?response_type=code&client_id=xxxxxxxxxxxxxx.apps.googleusercontent.com&redirect_uri=http://localhost:9002&scope=https://www.googleapis.com/auth/analytics.readonly&access_type=offline
The access_type=offline is because I'm using REST, and do not expect "the user" (myself) to manually deal with redirects / popups every time I need a refreshed token.
The above request returns http://localhost:9002?code=4/KModH0K_xxxxxxxxxxxxxxxxxxx9Iw.gikOaYRDWywTshQV0ieZDArCOX8XdwI
Code 4/KModH0K_xxxxxxxxxxxxxxxxxxx9Iw.gikOaYRDWywTshQV0ieZDArCOX8XdwI is my permission to request the API Token.
STEP #3: Request First Token
Because of my company’s IT issues, I’m forced to use PHP 5.2.17 and I do not have access to PHP cURL, so I’m using file_get_contents and stream_context_create.
The first token is requested with a PHP file_get_contents();
$opts = array(
'http' => array(
'method' => 'POST',
'header' => 'Content-Type: application/x-www-form-urlencoded',
'content' => 'code=4/KModH0K_xxxxxxxxxxxxxxxxxxx9Iw.gikOaYRDWywTshQV0ieZDArCOX8XdwI&client_id=xxxxxxxxxxxxxx.apps.googleusercontent.com&client_secret=yyyyyyyyyyyyyyy&redirect_uri=http://localhost:9002&grant_type=authorization_code'
)
);
$context = stream_context_create($opts);
$result = file_get_contents('https://accounts.google.com/o/oauth2/token', false, $context);
var_dump($result);
The content parameters must be in a single line.
The above code returns my access_token and refresh_token in json format
string(195) "{ "access_token" : "ya29.AHES6wwwwwwwwwwwwwwwVEBXE6XRbC-Q-pP0wZWdoIm9H804ro", "token_type" : "Bearer", "expires_in" : 3600, "refresh_token" : "1/8tXvdUKcSEcaaxVqqqqqqqqqqqqqoYpj2KSS9qwWI" }"
The refresh token I must store in a safe place, like a DB or protected txt file, which is called upon when my access_token has timed out.
STEP #4: Request Analytics Data
Now from what I understand, I’m ready to roll and should be able to use my access_token to make requests to https://www.googleapis.com/analytics/v3/data/ga.
I do this by sending this request;
$request = 'https://www.googleapis.com/analytics/v3/data/ga' .
'?ids=ga%3Aaaaaaaaa' .
'&start-date=2012-12-07' .
'&end-date=2012-12-09' .
'&metrics=ga%3Avisits';
$opts = array(
'http' => array(
'method' => 'GET',
'header' => 'Content-Type: application/x-www-form-urlencoded\r\n' .
'Authorization: Bearer ya29.AHES6wwwwwwwwwwwwwwwVEBXE6XRbC-Q-pP0wZWdoIm9H804ro \r\n'
)
);
$context = stream_context_create($opts);
$result = file_get_contents($request, FALSE, $context);
var_dump($result);
This request returns a 401 Unauthorized error. I take this as meaning my request is properly formed and making the connection to https://www.googleapis.com/analytics/v3/data/ga.
Also, according to this doc Getting Full Quota, I can make the request with the access_token in the URL like this;
$request = 'https://www.googleapis.com/analytics/v3/data/ga' .
'?ids=ga%3A48564799' .
'&access_token=ya29.AHES6wwwwwwwwwwwwwwwVEBXE6XRbC-Q-pP0wZWdoIm9H804ro' .
'&start-date=2012-12-07' .
'&end-date=2012-12-09' .
'&metrics=ga%3Avisits';
$result = file_get_contents($request, FALSE);
$result = json_decode($result);
var_dump($result);
This time I receive 403 error, in which google includes the response User does not have sufficient permissions for this profile.
QUESTION #1
Am I’m missing something in the API console or a process in the token acquisition? I’m assuming I’m not, because I’m ultimately acquiring the access_token=ya29 and refresh token.
QUESTION #2
Maybe I’m completely off basis in assuming I can do this with simple https reqests? Do I have to use the Google_Client and AnalyticsService classes? I don’t think this is the case, but maybe I’m wrong.
QUESTION #3
Do I need to use a ‘key’ in my request?
&key=bbbbbbbbbbbbbbbb
QUESTION #4
By using PHP 5.2.17 am I missing something? (besides 5.3 or 5.4 themselves)
For example, in some versions of PHP, in stream_context_create, the header should be in an array and not a string, like this;
$opts = array(
'http' => array(
'method' => 'GET',
'header' => array(
'Content-Type: application/x-www-form-urlencoded',
'Authorization: Bearer ya29.AHES6wwwwwwwwwwwwwwwVEBXE6XRbC-Q-pP0wZWdoIm9H804ro '
)
)
);
But I don’t think that it’s an issue in my case. I’m just curious if these HTTP request need to be formed a different way (without using curl).
Any insights and thoughts would be greatly appreciated
Here’s my dim witted mistake that nearly gave me a heart attack.
I typically do my development work in Chrome. And my Chrome browser was signed into my gmail account personal#gmail.com. However, my analytics account, which is under my work#gmail.com was open in FireFox (try not to laugh to hard).
I’m not 100% sure this is correct, but I think this is the general flow. When I did STEP #2: Request initial API access, I did this in my Chrome browser. The endpoint https://accounts.google.com/o/oauth2/auth was authorizing my personal#gmail.com account. And my STEP #4 API request https://www.googleapis.com/analytics/v3/data/ga was looking for an analytics profile under my personal#gmail.com account. Which of course doesn’t exist.
I literally wasted 15 hours on this. This is dumber than trying to troubleshoot an update… and forgetting to flush the cache.
Sorry for wasting your time.
EDIT REFRESH TOKENS
I've once again run into issues with this API and found out the hard way that GA will revoke Refresh Tokens if too many different clients use the token, at least I think that was the problem.
Further reading can be found here.
I got a 403 today and found the cause: in the get function I was using the account ID instead of the profile ID. Switching to the profile ID fixed it for me.
It could be a problem with CURL request. In the GoogleAnalyticsAPI.class.php > class Http > function curl (around line 720) add one more option to stop CURL from verifying the peer's certificate:
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);