Facebook Object with ID '' does not exist - for public, existing pictures - facebook-graph-api

For some odd reason I cannot get the picture data on API. Eg. for this picture https://www.facebook.com/10206158396036508
request:
curl -i -X GET \
"https://graph.facebook.com/v3.2/10206158396036508?access_token=(...)"
response:
Unsupported get request. Object with ID '10206158396036508' does not exist, cannot be loaded due to missing permissions, or does not support this operation.
Image is public and was found through facebook's search on pictures. I got the ID from the URL https://www.facebook.com/photo.php?fbid=10206158396036508&set=basw.A(...)&theater
Doing the same (search -> videos -> get ID from the URL to the video -> check it on Graph Explorer) works for videos but it doesn't on pictures for some reason I can't figure out... most other posts talk about private pics, but those are clearly public, so I should be permitted to query them just fine.

It does not matter if public or not, that picture is on a user profile and you can only get data of user profiles if that specific user authorized your App. In that case, the user_photos permission would be needed too.

Related

Create Facebook test page

I'm trying to create a test page on Facebook while developing an app. Per the instructions, I've created a test user, noted the user id and created an access token.
I'm now trying to make a POST request via curl to create a page
curl -i -X POST https://graph.facebook.com/v3.3/{user-id}/accounts?category_enum=MARKETING_AGENCY&name=Test%20Page&access_token={access-token}
However the response is an error
(#100) The parameter name is required
Seems I have supplied the name parameter though; any ideas?
EDIT
If I remove the category_enum param, the error becomes
(#283) Requires manage_pages permission to manage the object
However, I have verified the user has the manage_pages permission....
Beware of the facebook api documentation... On the surface it looks like only the name parameter is required, however after hours of experimentation with the Graph API Explorer I managed to create the test page with no less than 9 required parameters!

Instagram Graph API

My task is to get photo data of my business Instagram account with Instagram Graph API. I followed the instruction from Instagram Graph API -
https://developers.facebook.com/docs/instagram-api/reference/user/media
, which said request like
GET http://graph.facebook.com/17841405822304914/media
can get photo data from the Instagram account linked to the FB account in JSON format.
I tried to send GET request /my_facebook_id/media as said by the document with Graph API Explorer on FB developer platform but it failed to return the data I want.
This is the error I got:
message: Tried accessing nonexisting field (media) on node type (User)
type: OAuthException code: 100
Does the message mean the media field doesn't exist in the FB user?
What is the meanIng of error code 100? I can't even see that in FB official document.
I tried to use the Instagram business account ID for this request but I got an error message said the user object doesn't exist
How to get the task done? Thanks!
I guess you have missed creating a Facebook business page and linking your Instagram Business account to it.
Here is the guide to setup : https://developers.facebook.com/docs/instagram-api/getting-started
If this was done correctly and still you're facing the error is because of a Facebook bug where your account doesn't get linked correctly.
Here : https://developers.facebook.com/support/bugs/177912116363088/?disable_redirect=0
Solution : Please disconnect your Instagram account from your page. Then, on Instagram app, in setting you will have to switch back to personal account and reconvert to a business account
Note : Switching to a personal account you will lose the insights of your media.
Once this is done you should be able to get instagram_business_account and post which you can run your query to fetch the media :
GET http://graph.facebook.com/you-instagram-business-account-id/media

How to retrieve a facebook photo of a different user, is this possible?

I'm trying to retrieve a photo of a user different from the logged one, here what I did:
I have 2 different users that granted "user_photos" permission to my app
I'm able to retrieve the photos uploaded by USER_1 through the API
https://graph.facebook.com/v2.5/me/photos/uploaded?access_token=USER_1_TOKEN
Let's suppose I'm interested in the photo with id PHOTO_ID_123 (privacy public) and I want USER_2 to be able to view that photo. I should call the following API:
https://graph.facebook.com/v2.5/PHOTO_ID_123?access_token=USER_2_TOKEN
(note the different token user in the latter call)
The issue is that now I'm getting the following error from FB:
{
"error": {
"message": "Unsupported get request. Please read the Graph API documentation at https://developers.facebook.com/docs/graph-api",
"type": "GraphMethodException",
"code": 100,
"fbtrace_id": "GmYciGz/Mpd"
}
}
These two users are mutual friends on facebook, but since the photo is public I expect to be accessible even in case the two users are not mutual friends.
Of course the following API call
https://graph.facebook.com/v2.5/PHOTO_ID_123?access_token=USER_1_TOKEN
is working as expected (it does return photo related data). If USER_2 try to access PHOTO_ID_123 from browser (inside facebook website), he can see the photo.
What am I missing? Is this even possible? To me it seems possible from fb doc: https://developers.facebook.com/docs/graph-api/reference/photo/
Permissions
Any valid access token can read photos on a public Page. A page access
token can read all photos posted to or posted by that Page. A user
access token can read any photo your application created on behalf of
that user. A user's photos can be read if the owner has granted the
user_photos or user_posts permission. A user access token may read a
photo that user is tagged in if they have granted the user_photos or
user_posts permission. However, in some cases the photo's owner's
privacy settings may not allow your application to access it.
Thanks
If i authorize an App with user_photos, i would not want any other App User to be able to see my photos - at least not without my permission per photo. So it does make sense not to be able to access photos of one user with the Token of another.
You could let the User select some photos and store it on your server if you want that to happen. Just because something is public on facebook.com does not mean you can grab it with the API, that would make a lot of permissions pointless.

Get comments of public facebook post

I'm trying to download every comment on a public facebook post (it's one of those "can you do this basic algebra problem" posts - I want to see what percent of the comments get it right).
The Graph API Reference shows that I should be able to just GET graph.facebook.com/v2.5/{object-id}/comments.
I believe the object-id of this post is {user-id}_{post-id}, where post-id is the id in the url. So given this url:
https://www.facebook.com/beth.mansfield.9/posts/10207885721596563
The user-id of facebook.com/beth.mansfield.9 is 1101752663 (from findmyfbid.com), and the post-id is 10207885721596563 (from the url), which makes the object-id="1101752663_10207885721596563".
When I try graph.facebook.com/v2.5/1101752663_10207885721596563/comments in the Graph API Explorer, though, I get:
{
"data": [
]
}
What am I doing wrong? Is there another way to get the comments? There are close to a million so loading them all in the browser and scraping with javascript would be unfeasible.
That is a user profile. You can only get data of a user profile if that specific user authorized your App. In that case, you would need to authorize with the user_posts permission. Just because it is public, does not mean you can get the data - that would only work for Pages.

Facebook api-why do i need a token?

I have read almost all the graph API and i don't get this thing at all .
I am some user, who needs to get some other public page photos . thats it,very simple.
So to do that, i can just :
https://graph.facebook.com/page id/photos/uploaded/
Which is works great. gives a json with the photos .
BUT ,Facebook is always talks about this tokens everywhere. you need a token to everything .
So after so much frustration i have got this token i created to some app i made.
Problem is, what i do with this token ?? i don't see any place in the API where i put this token in the http request .
Take this request i showed here for example, it works for any page without a token. so where goes the token? why do i need it ?
Why when talking about getting images of some page they always say you must be the admin of that page? NO I DONT want to be the admin of a page, i just want to get photos of other page, that i don't own, with a simple http request.
Everything is messed up for me .
You can apply an access_token to any Graph API request by appending ?access_token=xxx to the URL. In your example, the resulting URL would be:
https://graph.facebook.com/page id/photos?access_token=xxx
The access_token is typically used to access any data that isn't public. While its true that you don't need an access_token or be an Admin of a page to get Photos, you may still need an access_token to access pages with location or age restrictions.
For example, I can easily get public photos from the Coca Cola page:
https://graph.facebook.com/cocacola/photos
But not for this protected page (since you must be 18+ to access this page):
https://graph.facebook.com/Betfair/photos