Facebook Graph API : get satuses with photos on user's feed - facebook

I'm trying to get user's own posts on with images on his feed.
GET https://graph.facebook.com/USER_ID/photos/uploaded
will get me the uploaded images but without the status they were posted on.
on the other hand,
GET https://graph.facebook.com/USER_ID/feed?fields=message
will work just fine , but
GET https://graph.facebook.com/USER_ID/feed?fields=message,attachments
is returning me this
{
"error": {
"type": "http",
"message": "unknown error",
"status": 500
}
}
(FYI as for v2.1 FQL is deprecated)
help?

To my knowledge, you have to do USER_ID/feed and then filter out the posts that aren't images. In those kinds of objects, there is no attachment field. There isn't any way of filtering content in Graph API like you could do in FQL. You would have to get the post type which I'm pretty sure is the field type.

Related

Retrieving photo likes through Facebook's Graph API

I want to store information about photos of Facebook pages.
I use for example this call to the graph API: https://graph.facebook.com/328548953909061/albums?fields=count,id,name,cover_photo,type,photos{id,name,created_time,picture,source,link,likes}&$acces_token
Since a couple of weeks I get this error:
{
"error": {
"message": "Unsupported get request.",
"type": "GraphMethodException",
"code": 100
}
}
When I remove ",likes" from the url it works. Anyone knows what is going wrong here?
In your initial call you need add v2.1
https://graph.facebook.com/v2.1/328548953909061/albums?...
Additionally I would call the following.
https://graph.facebook.com/v2.1/328548953909061/albums?fields=count,id,cover_photo,type,photos{id,name,created_time,picture,source,link,likes.summary(true).filter(stream)}&access_token=...
Adding .summary(true) and .filter(stream) to the likes field will give you a Summary doc in the photo doc and Filter will force all the nodes in to the count. Facebook "hides" some nodes of low "Top Story" value.

Facebook Graph API - Retrieve photo - Unsupported get request

I am testing the Facebook Graph API via their explorer. I managed to get my feed using me/home. However, I want to get some details from uploaded pictures.
As I read on other posts, I have to re-run the query using the object_id in the POST object.
This only works for public images. Whenever I try to do this on a friend's photo, I get:
{
"error": {
"message": "Unsupported get request. Please read the Graph API documentation at https://developers.facebook.com/docs/graph-api",
"type": "GraphMethodException",
"code": 100
}
}
One of them was a photo of my wife. I checked her privacy setting, as far as I can see, she doesn't block 3rd party API's.
How can I get photo details of posts that the API returns in me/home?
I know that it doesn't work for photo's with unique permissions (so e.g. with tags in them), but I tested it with photo's only shared with that person's friends. Tested about 10, none of them work. How is this possible?

Facebook API Video Views

I want to get the views of a video on my Facebook page.
My request:
{object-id}/insights/post_video_views_organic
But instead of data I get the following error back:
{
"error": {
"message": "(#100) Tried accessing nonexisting field (insights) on node type (Video)",
"type": "OAuthException",
"code": 100
}
}
I havenĀ“t really worked with the Facebook API in the past so I cant really translate this error message.
(I am using the Graph API Explorer)
Try adding the id of your facebook page (which you can retrieve through the Graph API or here) to the start of the object id, followed by an underscore ('_') then the object id of the video.
Instead of "{object-id}/insights/post_video_views_organic".
Use "{post-id}/insights/post_video_views_organic" . You will get the metrics.
The "post-id" is post id of that video post.

FB Graph API return unsuported get request even public post without restriction

I try to retrieve post's information from Graph API:
https://graph.facebook.com/100006679472813_1392957120936924?access_token={my_access_token}
The Facebook Graph response:
{
"error": {
"message": "Unsupported get request.",
"type": "GraphMethodException",
"code": 100
}
}
However, I can access the post by this link (same user as {my_access_token}) https://www.facebook.com/100006679472813_1392957120936924
And I can receive the original message of this post via Graph Search API too.
Not all posts return error. But so many do. How can I get it's detail via Graph API?
You can not read all the posts in the facebook. If you try to fetch the details of the post by the user other than the user in the session, you may or may not get the details of the post. This depends on the privacy settings of the user. So, only the public posts can be fetched (in case of other users)

Why do I get this error when I try to access a certain type of object via the Facebook Graph API?

I have a user, user_2. There is a post on their wall, made by user_1.
The URL is
https://www.facebook.com/user_1/posts/10150166228506188
I try to get the content using the Graph API, with this request:
https://graph.facebook.com/10150166228506188?access_token=ACCESSTOKENUSER_2
I get this error:
{
"error": {
"type": "GraphMethodException",
"message": "Unsupported get request."
}
}
The access_token I am using is good, because requests to get things like statuses & images work fine:
https://graph.facebook.com/10150233707783933?access_token=ACCESSTOKENUSER_2
Result:
{
"id": "10150233707783933",
"from": {
"name": "American Steel",
"category": "Professional sports team",
"id": "203692078932"
},
"tags": {
"data": [
etc
The error seems to happen whenever I try to get items that have this kind of URL:
https://www.facebook.com/username/posts/item_id
The permissions my app has include these:
Why is this error occurring?
I think that, in order to access the posts directly through the graph api, you have to prepend the user id to the post id you see in the facebook url.
So in your example the facebook post url is :
https://www.facebook.com/user_1/posts/10150166228506188
And you try to get through the graph api :
https://graph.facebook.com/10150166228506188?access_token=ACCESSTOKENUSER_2
BUT you should be doing :
https://graph.facebook.com/{id of user_1}_10150166228506188?access_token=ACCESSTOKENUSER_2
I noticed that all posts ids are formed like this by visiting :
https://graph.facebook.com/me/posts?access_token=...
Does this solve your problem ?
You're accessing the end-point of the post incorrectly. Every object on Facebook has a unique ID. Right now, it just so happens that they form it by appending different IDs together (your post is an example, <user_id>_<post_id>, and for a comment on that post it'd be <user_id>_<post_id>_<comment_id>). Facebook hasn't made public acknowledgment of this (not that they really have to, it's obvious) which makes me leary to rely on that paradigm for accessing data within the graph. This is because Facebook could change it at any point, and the fact that they haven't said "yeah append these 2 ids together and you can get something meaningful from this part of the graph" means they won't have to notify anyone about the change, you could just wake up one day and your app be completely broken and you'd have to find a work around quickly and while suffering down time.
The graph api works by accessing objects on Facebook by making a request to the API for that unique ID. So, you don't need to access (and can't access) your posts by going to graph.facebook.com/<user_id>/posts/<post_id>. Instead, you go to graph.facebook.com/<post_id>. You get the post_id from the /<user_id>/home or /<user_id>/feed end-point on the graph. There is no need to modify a post_id in order to fetch information about it from the graph.
Hope that helps