Facebook Graph API - Service temporarily unavailable OAuthException - python

I am attempting to scrape the statuses of a public facebook place via version 2.11's posts endpoint. The generated URL I am calling is as follows:
https://graph.facebook.com/v2.11/41585566807/posts?access_token=XXX&fields=message%2Clink%2Ccreated_time%2Ctype%2Cname%2Cid%2Ccomments.limit%280%29.summary%28true%29%2Cshares%2Creactions.limit%280%29.summary%28true%29&limit=100&after=Q2c4U1pXNTBYM0YxWlhKNVgzTjBiM0o1WDJsa0R5QTBNVFU0TlRVMk5qZA3dOem90TmprM05qWTFOREEwTmprMU1qUTVOREEwTXc4TVlYQnBYM04wYjNKNVgybGtEeDAwTVRVNE5UVTJOamd3TjE4eE1ERTFNRFF6TmpjME5UZAzNOamd3T0E4RWRHbHRaUVpPcUpBRUFRPT0ZD
I am paging through chunks of 100 statuses to return them all. This method works great for the first 2600 statuses on the page, but once I try to get the next 100, I get the following error message.
{
"error": {
"message": "(#2) Service temporarily unavailable",
"type": "OAuthException",
"is_transient": true,
"code": 2,
"fbtrace_id": "EezWeUvcCXd"
}
}
Even though, is_transient is true, it lasts through hours of repeated calls (every 5 seconds) to the api. Any idea why this error message is occurring and how to avoid it?

Related

Facebook Insights API

I am using Facebook Insights API for pulling clicks, impressions, and spending for the last 90 days. Our code is able to pull rows up to 8K, if the response goes higher the code throws the following error.
Error while getting rows from API,
Message: Call was not successful
Method: GET
Path: https://graph.facebook.com/v13.0/act_**********/insights
Params: {'fields': '["account_id","account_name","campaign_id","campaign_name","adset_id","adset_name","impressions","clicks","spend"]', 'date_preset': 'last_90d', 'time_increment': 1, 'level': 'adset', 'limit': '500'}
Status: 500
Response:
{
"error": {
"code": 1,
"message": "Please reduce the amount of data you're asking for, then retry your request"
}
}
Is there a way to resolve this issue or do we need to report to the Facebook team to increase limits?
Thanks,

YouTube API v3 - Python - how to batch insert playlistItems

I've been using the Youtube API to add multiple playlistItems to playlists on my profile, but doing so with loops tends to use up my daily request quota and I've hundreds to add.
I'm sending <50 video IDs per batch
the video IDs are all valid, and can be added succesfully one at a time
The new_batch_http_request method seems to be the solution but roughly 1 in every 4 video ids within the batch ends up failing. On Googling the problem it might be related to the position leading to overwrites?
Using this example, the first and third items were successful but the 2nd failed:
from Google import Create_Service
CLIENT_SECRET_FILE = 'client_secret_file.json'
API_NAME = 'youtube'
API_VERSION = 'v3'
SCOPES = ['https://www.googleapis.com/auth/youtube',
'https://www.googleapis.com/auth/youtube.force-ssl']
service = Create_Service(CLIENT_SECRET_FILE, API_NAME, API_VERSION, SCOPES)
playlistItemsList = ['eDTnKLqFuYU', 'TT7plfxWK6E','oMbL_7lpD1w']
batch = service.new_batch_http_request(callback=insert_video)
for videoId in playlistItemsList:
batch.add(
service.playlistItems().insert(part="snippet",
body={"snippet": {
"playlistId": "PLs7sB4wt2IftzifT5G4cdjQlXZQpEk2Go",
"position": 0,
"resourceId": {"kind": "youtube#video", "videoId": videoId},
}
},
),
)
request = batch.execute()
Using the callback function I can see that the failed attempts are returning:
<HttpError 500 when requesting https://youtube.googleapis.com/youtube/v3/playlistItems?part=snippet&alt=json returned "Internal error encountered.". Details: "Internal error encountered.">
{
"error": {
"code": 403,
"message": "The request is missing a valid API key.",
"errors": [
{
"message": "The request is missing a valid API key.",
"domain": "global",
"reason": "forbidden"
}
],
"status": "PERMISSION_DENIED"
}
}
Is there a way to sequentially add to playlist but utilising a batch method?
I noticed a serialise batch request within Google API docs - could this be what I'm looking for?
https://googleapis.github.io/google-api-python-client/docs/epy/googleapiclient.http.BatchHttpRequest-class.html#_execute
My code is based on this:
https://learndataanalysis.org/copy-videos-from-any-youtube-playlist-to-your-own-playlist-with-python-and-youtube-api/

Resource has been exhausted Google Cloud Speech

I am trying to transcribe a 45 min long audio file with google cloud speech but I keep getting
Resource has been exhausted (e.g. check quota)
I have the free credit that the api offers you for a year. Tried it in the api explorer and in python where I will be using it but the result is the same. This is the request I send:
{
"audio": {
"uri": "gs://speech_summarization/mq.3gp"
},
"config": {
"encoding": "AMR",
"sampleRate": 8000
}
}
and response:
429
- Show headers -
{
"error": {
"code": 429,
"message": "Resource has been exhausted (e.g. check quota).",
"status": "RESOURCE_EXHAUSTED"
}
}
I saw similar problems solved by cutting the video in shorter versions but with 10 min it didn't work for me. Any ideas?
Files under 1 minute are working because, in addition to an absolute quota on audio sent to the API there are specific limits on streams of audio:
https://cloud.google.com/speech/limits
I haven't had much luck finding a free version (even on trial) of transcription products like those offered by Nuance.

YouTube api Error

I am a little confuse! I am trying to develop a script that can pull youtube video id in python. So I went ahead and set up my youtube API key.I use this page to generate the URL.
https://developers.google.com/youtube/v3/docs/search/list
This page generated a sample JSON table with the video ID. But when I put this url in my browser
https://www.googleapis.com/youtube/v3/search?part=id&q=gullybop&key={YOUR_API_KEY}
and yes I filled in my api. I expected to get back a JSON table with the vid ids but I get this instead
"error": {
"errors": [
{
"domain": "usageLimits",
"reason": "keyInvalid",
"message": "Bad Request"
}
],
"code": 400,
"message": "Bad Request"
}
}
I don't think my API key is invalid
I expected when I put the URL in the browser it would return a JSON table with vid ids but instead I got that error above.
Why am I getting this error ?
Thank you Sean
I got JSON results when I accessed this URL with my API Key. So your API key will be invalid nothing else. Try to create another project in API console and create a key without any referrer no server IP. Only generate 1 key in a project. Dont forget to enable YouTube Data API v3 in API manager.

getting friendlist from facebook graph-api

I am trying to get user's friend list from facebook Graph-api. So after getting access token when I try to open by urlopen by
https://graph.facebook.com/facebook_id/friends?access_token=authentic_accesstoken
this doesn't give friend_list of person(facebook_id) not even when I open it directly on the browser, at least not the entire list. This is what it shows on the browser
{
"data": [
{
"name": "Face_id_name",
"id": "facebook_numeric_id"
}
],
"paging": {
"next": "https://graph.facebook.com/v2.2/facebook_id/friends?access_token=authentic_accesstoken&limit=25&offset=25&__after_id=enc_Some_encrypted_code"
},
"summary": {
"total_count": 263
}
}
In data it doesn't show the entire list and when I use link to paging: next: it doesn't give me anything just total count again.
I am not entirely sure whether my url is right or not.
You canĀ“t get the friends of ANY user, you can only get the friends of the authorized user and only those who authorized the App too - for privacy reasons. So this is the only correct call:
https://graph.facebook.com/me/friends?access_token=authentic_accesstoken
There is no need to use the ID, because you can only use the ID of the authorized user anyway. So you can just use "me" instead.
More information about the limited friend result can be found in countless other threads, for example: Facebook Graph Api v2.0+ - /me/friends returns empty, or only friends who also use my app

Categories