Google Photos Library API IDs are invalid - google-photos

Cached IDs of media items, albums and enrichment items stopped working.
For example, calling mediaItems.get with a media item ID that was stored returns the following error:
{
"error": {
"code": 400,
"message": "Invalid media item ID.",
"status": "INVALID_ARGUMENT"
}
}

The format of all IDs returned by the Google Photos Library API changed on September 5.
If you have stored IDs such as albums ids, media item ids, or enrichment item ids before 5th September 2018, these will no longer work as the format of the IDs has changed recently. Obtain new IDs for use in your application.
You can make a request again to retrieve the new IDs, for example by listing the library contents, albums or submitting another search request.
See the API release notes for more information

Related

How to post a photo to a page with a tagged Product via Graph API v12.0?

We have a Facebook Shop and a Business Page, and are using Facebook Graph API to create Photo posts on the Business Page using the Javascript SDK running in a browser. How do you include the tagged Product in the Create Photo request?
https://developers.facebook.com/docs/graph-api/reference/photo/ mentions a tags field you can pass which is described as "Tags on this photo", however it has a tag_uid "The user_id of the tagged person". Is this tags field how you are supposed to tag a product?
A similar question from 2017 was not answered and is so old I thought I'd post a new one: Publish new facebook post with tagged product
What we've tried so far
To get a list of our products, we can use GET ${businessId}/owned_product_catalogs to retrieve a list of catalogs, and then GET ${productCatId/products with a filter: '{"custom_label_0":{"eq":"something_to_match"}}' to get a specific product in the catalog. So now we have the ID of a product we want to tag e.g. "4378279312278116". (we happen to use custom_label_x fields meaningfully, of course the filter could have been something else but this works for us)
To create the photo post, we can POST /${account.id}/photos with a payload like:
{ caption: 'Test caption',
url: image_url,
access_token: account.access_token,
tags: [
{
tag_uid: "4378279312278116",
tag_text: 'Test tag',
x: 10, y: 10
}
]
}
This request completes OK and does post the photo, but nothing is tagged on it when we view it on our page.
Trying to read the photo with GET ${photo_id} only returns basic infomation fields created_time, id, name. I can't see how to read further fields on the photo object to check if the tags data was associated with it correctly.
Any advice please?

Instagram Graph API - Fetch media insights metric when a user switched from personal to business account

I'm looking for a way to fetch Media Insights metrics in Instagram Graph API (https://developers.facebook.com/docs/instagram-api/reference/media/insights) with a nested query based on the userId, even when a client switched from a Personal to a Business account.
I use this nested query to fetch all the data I need : https://graph.facebook.com/v3.2/{userId}?fields=followers_count,media{media_type,caption,timestamp,like_count,insights.metric(reach, impressions)} (this part causes the error: insights.metric(reach, impressions) - it works however for an account that has always been a Business one)
However, because some media linked to the userId were posted before the user switched to a Business account, instead of returning the data only for the media posted after, the API returns this error:
{
"error": {
"message": "Invalid parameter",
"type": "OAuthException",
"code": 100,
"error_data": {
"blame_field_specs": [
[
""
]
]
},
"error_subcode": 2108006,
"is_transient": false,
"error_user_title": "Media Posted Before Business Account Conversion",
"error_user_msg": "The media was posted before the most recent time that the user's account was converted to a business account from a personal account.",
"fbtrace_id": "Gs85pUz14JC"
}
}
Is there a way to know, thru the API, which media were created before and after the account switch from Personal to Business? Or is there a way to fetch the date on which the account was switched?
The only way I currently see to get the data I need is to use the /media edge and query insights for each media until I get an error. Then I would get approximately the date I need. However, this is not optimized at all since we are rate limited to 200 calls per user per hour.
I have the same problem.
For now, I'm Switch between queries (if first have error)
"userId"?fields=id,media.limit(100){insights.metric(reach, impressions)}
"userId"?fields=id,media.limit(100)
I show the user all insights in zero.
I don't know if they're the best alternative, like identify the time of conversion to business and get the post between this range of DateTime
I got the same problem and solved it like this:
Use the nested query just like you did, including insights.metric
If the error appears, do another call without insights.metric - to at least get all other data
For most accounts, it works and there is no additional API call. For the rest, i just cannot get the insights and i have to live with it, i guess - until Facebook/IG fixes the issue.
I got the same problem and solved it like this:
Step1: Convert your Instagram account to a Professional account.
Step2: Then According to Error Post a new post on Instagram and get their Post-ID.
Step3: Then try to get a request using that Post-ID.
{Post-ID}?fields=comments_count,like_count,timestamp,insights.metric(reach,impressions)
curl -i -X GET "https://graph.facebook.com/v12.0/{Post-ID}?fields=comments_count%2Clike_count%2Ctimestamp%2Cinsights.metric(reach%2Cimpressions)&access_token={access_token}"
For more: insights
Here is the relevant logic from a script that can handle this error while still doing a full import. It works by reducing the requested limit to 1 once the error is encountered. It will keep requesting insights until it encounters the error again, then removes insights from the fields and returns to the requested limit.
limit = 50
error_2108006 = False
metrics = 'insights.metric%28impressions%29%2C' # Must be URL encoded for replacement
url = '/PAGE_ID/media?fields=%sid,caption,media_url,media_type&limit=%s' % (metrics, limit)
# While we have more pages
while True:
# Make your API call to Instagram
posts = get_posts_from_instagram(url)
# Check for error 2108006
if posts == 2108006:
# First time getting this error, keep trying to get insights but one by one
if error_2108006 is False:
error_2108006 = True
url = url.replace('limit={}'.format(limit), 'limit=1')
continue
# Not the first time. Strip out insights and return to desired limit.
url = url.replace(metrics, '')
url = url.replace('limit=1', 'limit='.format(limit))
continue
# Do something with the data
for post in posts:
continue
# If there are more pages, fetch the next URL
if 'paging' in posts and 'next' in posts['paging']:
url = posts['paging']['next']
continue
# Done
break

Is there a way to update and delete a Glip team or group?

I can retrieve a list of groups/teams or an individual one by using the chats API, but I cannot find how to update or delete a group or a team.
The GET APIs I use successfully include:
Get Chat List
GET https://platform.ringcentral.com/restapi/v1.0/glip/chats
Get Chat Info by ID
GET https://platform.ringcentral.com/restapi/v1.0/glip/chats/{chatId}
However, when I try to call PATCH or DELETE on the Chat ID API endpoint I receive a 404. Is there a way to delete a Glip team or group?
chats is a new endpoint to cover both Groups and Teams, however PATCH and DELETE have not been implemented on it yet.
Update Team
To update a team, use the old teams endpoint. The teamId below are the same as the chatId provided in the id property returned by the "Get Chat List" API.
Only the following body parameters are supported. Use the one(s) you wish to update.
PATCH https://platform.ringcentral.com/restapi/v1.0/glip/teams/{teamId}
{
"public": true,
"name": "My New Team Name",
"description": "My Fancy Team"
}
A successful PATCH will return a 200 OK response with a JSON body of the team properties.
Delete Team
To delete a team, use the old teams endpoint. The teamId below are the same as the chatId provided in the id property returned by the "Get Chat List" API.
DELETE https://platform.ringcentral.com/restapi/v1.0/glip/teams/{teamId}
A successful response will result in a 204 No Content response status code.
Update Group
There is no option to update a group as it is just a chat with multiple participants.
Delete Group
It is not possible to delete a Group or a PrivateChat. Attempting to do so will result in the error below. To delete a Group, convert it to a Team first and then delete it.
HTTP 400 Bad Request
{
"errors": [
{
"errorCode": "CNV-001",
"message": "Conversation with type [Group] cannot be deleted."
}
]
}

How to scrape user's facebook feed using Graph API?

I'd like to scrape some user's posts from Facebook. Posts are visible in browser, when I'm logged in and I am looking at http://fb.com/username URL. But when I'm trying to access the same feed using Graph API Explorer (https://graph.facebook.com/v2.3/username/feed) I'm getting:
"error": {
"message": "(#803) Cannot query users by their username (username)",
"type": "OAuthException",
"code": 803
}
If I try to use id instead of username (http://graph.facebook.com/v2.3/userid/feed) I'm getting empty JSON in response:
{
"data": [
]
}
So, is there a way to get the user's feed using Graph API? Or do I have to imitate a web browser and parse HTML then?
You are not supposed to grab the feed of any user, public or not. You need to authorize a user with user_posts to get access to his feed - and his feed only.
Also, usernames are not available in the Graph API anymore, you need to use an App Scoped ID now. You get that when you authorize the user.
Btw, scraping is not allowed at all: https://www.facebook.com/apps/site_scraping_tos_terms.php

Facebook API: Error "(#210) Subject must be a page" when posting a Status Update on a Page

I want to post a simple status update on one of my pages with a perl-script. To find out how to do best, I use facebooks Graph API Explorer https://developers.facebook.com/tools/explorer for experiments
I use the access token of my FB-app. This app is doing a good job since 2 years. The access token will expire in about 2 month and among many other permissions it has the permissions "publish_stream" and "manage_pages".
I select "POST", then, in the field next to "POST", I enter the ID of my page (a 15-digit-number starting with 102 ending with 937). This ID is correct, because I can GET data from this page using exactly this ID.
I click on "Add a field", then I enter the field-name "message" and the value "test-message". Then I click on "Submit". And then I get this result:
{
"error": {
"message": "(#210) Subject must be a page.",
"type": "OAuthException",
"code": 210
}
}
But posting a comment to an existing posting on the same page works fine. I simply replace the page-ID 102...937 with 501...852/comments where "102...937" and "501...852" are 15-digit-numbers.
What am I doing wrong? What must I do to post a message on my page using the Graph API Explorer? "102...937" is the ID of an existing page. I am managing 3 pages, I have the same problem with all 3 IDs.
I found the solution:
In the field next to POST I only did enter the Page-ID (like 123456789012345) but you must add "/feed" to the end, like this: 123456789012345/feed
The documentation does not say how to post a status message. To me it was clear, If want to post something on a page, I have to enter the pages ID, not more. And if the error-message would have said "Subject must be a FEED" everything would have been clear. But is said "must be a PAGE" but it already was a page.