Get URL (Link) for facebook post using post ID - facebook

I am trying to get a post from a company Facebook page.The link is for an application i developed that feeds of information from another applications database that uses the Facebook API.
i want to create a link eg www.facebook.com/{postID} that will take me to the specific post.I have tried numerous articles and all seem to send me to a 404 page. Please help.
Thanks

My Application uses the facebook api that accepts data related to a facebook page content (i.e posts,photo's,statuses etc).part of the api is that it saves the actual post id pertaining to a post for e.g. 302961133120433_576487772434433 into my applications database.As you may see that the post id has 2 parts separated by an underscore.So i needed to make a url based on this post id.
Solution for the link is:(2 parts of it,first being page id and second being actual post id)
Hope this helps.

You have facebook API doc on post here : https://developers.facebook.com/docs/graph-api/reference/v2.8/post
the URL you want is called "permalink_url" as field name, so the API call to get that link is in this format:
URL = 'https://graph.facebook.com/v2.8/' + postId + '?fields=permalink_url&access_token=' + facebookToken
Here is a screenshot for my testing in FB API explorer.

If you want to get a list of posts on IDs on a particular page, it doesnt seem to be documented but this works:
https://graph.facebook.com/teapartypatriots?fields=posts.id&access_token=<TOKEN>

If anyone only needs to redirect to the post URL, just put the post id after https://www.facebook.com/ and it will be automatically taken to the post.
more information from the official docs https://developers.facebook.com/docs/pages/publishing/

Related

Facebook - How to post feed on company page using custom name

I am able to successfully post content to Company Page using the Facebook Graph API.
I have a query to know how to pass Personal Name or Company Name while posting the content.
I am referring to URL: https://developers.facebook.com/docs/graph-api/reference/page/feed/ to post the content but didnt find out parameter for passing Personal Name/Company Name.
Please reply me as soon as possible.
Thanks,
Chirag

Facebook Graph API get all comments

I've put a Facebook social plugin comments box on my site, in which i specified a Facebook Fanpage, as the comments target.
Now what I want to do is get all comments that are present in the comments box on page my page. I'm using this:
https://graph.facebook.com/comments/?ids=xxx
In place of xxx I placed my fanpage url (displayed comments just from one day even with limit set to 10000) and when this didn't work I tried my page url, which resulted in nothing being displayed.
The correct syntax to read comments from the Facebook Graph API is as follows:
GET /{object-id}/comments
So your URL would look like this:
https://graph.facebook.com/xxx/comments
Here's a live example that looks at comments on Coca-Cola's cover photo:
http://graph.facebook.com/10152297032458306/comments
You can read more about reading comments via the Graph API here.
check this stackOverflow topic
You need to call it from a secure request https and provide an access_token (19292868552_118464504835613 is Facebook post) :
( (19292868552) is the page or group id and (118464504835613) is the post id)
https://graph.facebook.com/19292868552_118464504835613/comments?access_token=XXX
EDIT:
Added the object from the post document. Try clicking the comments connection and then remove the access_token and try and see the difference.

Get all pictures and related comments from a Facebook Group page

I need to get all picture and their related comments which has been made to a particular facebook group page. How can I achieve this through facebook api?
Sure, you just need to make a request to graph.facebook.com/GROUP_ID/feed
Example here: https://developers.facebook.com/tools/explorer?method=GET&path=173972555961507%2Ffeed
The Graph API is really easy to figure out. You have the base url (graph.facebook.com) and then you can make requests to any object on facebook (user, page, group, checkin, etc) by just calling graph.facebook.com/OBJECT_ID. It's all on the front page: https://developers.facebook.com/docs/reference/api/

How to find a post when all you know is the post_id?

I have a simple app for submitting data and after submission I have a share option.
When a user actually shares something he is redirected by Facebook to a specified URI.
Facebook also provides the post_id by appending it to the URI (like http://my-redirected-URL?post_id=100001175803635_321643121201516).
So, without asking anything from the user, I can tell if he shared information or not, and I have his post_id (but not his user_id or name).
But how can I see what he actually wrote? I have his post_id. Where can I look?
I've tried the open graph but with no luck.
I thought this was an answer: what is the url to a facebook open graph post id?, also no luck.
Any ideas?
If you have user access_token for user who shared the content you can issue GET request to Graph API to get the data by post id (100001175803635_321643121201516 for example):
GET https://graph.facebook.com/POST_ID?access_token=USER_ACCESS_TOKEN
Response is the Post object which will have non empty message property if user added some text to shared content...

Facebook graph API: feeds missing in json response

I try to fetch user's feeds via graph api from my Android application. It generally works but some feeds that I can see on the wall are missing in the json response.
I call the url http://graph.facebook.com/someUserId/feed, by using the Android Facebook SDK methods, so the access token should be provided automatically, but it's not really relevant I think in my case. Nevertheless fyi, the user of my app is authenticated via OAuth.
I already checked the following:
all the user's feeds are visible to everyone / public (set in privacy settings)
the json response is not cached by my browser
I am aware of paging, but this is not an issue. The problem is not that I am not getting the very oldest feeds but that some feeds are just missing in between.
I registered a new facebook user which is not connected to the user I want to retrieve the wall feeds from, and when I open the respective wall I see all the feeds there, as expected, since they're all public to everyone. Yet, when I open the same related json url unter http://graph.facebook.com/someUserId/feed, some feeds are missing.
This is an example of the problem - since all my posts are public, I can just call the json url directly in a browser to do a test.
I want to get wall feeds from user:
http://www.facebook.com/mathias.lin
Screenshot1: note the 3 marked postings, all posted by myself
and here the json response, as you can see, the 1st and 3rd wall posts are included in the json, but the 2nd post is not. Why?
The related json url is:
http://graph.facebook.com/mathias.lin/feed
I am getting the 'missing' feed when I add an access_token to the url - but why? The posted feed has a privacy setting for 'everyone'?!
This is the missing feed that I get when using the access_token:
{"id":"504063796_485195138796","from":{"name":"Mathias Lin","id":"504063796"},"message":"Photo test upload from Android","picture":"http:\/\/photos-e.ak.fbcdn.net\/hphotos-ak-snc6\/hs021.snc6\/165194_485195123796_504063796_6062399_1841907_s.jpg","link":"http:\/\/www.facebook.com\/photo.php?fbid=485195123796&set=a.485195118796.256450.504063796","name":"Torres Photos","icon":"http:\/\/static.ak.fbcdn.net\/rsrc.php\/yz\/r\/StEh3RhPvjk.gif","actions":[{"name":"Comment","link":"http:\/\/www.facebook.com\/504063796\/posts\/485195138796"},{"name":"Like","link":"http:\/\/www.facebook.com\/504063796\/posts\/485195138796"}],"privacy":{"description":"Everyone","value":"EVERYONE"},"type":"photo","created_time":"2011-01-06T05:10:43+0000","updated_time":"2011-01-06T09:00:23+0000","likes":6,"comments":{"data":[{"id":"504063796_485195138796_3607414","from":{"name":"Mathias Lin","id":"504063796"},"message":"Awesome, photo upload now works as well. Not so much fun working with the Facebook SDK for Android, would have expected more functionality beyond that just very very simple graph api wrapper. But need to be considered that the android sdk development was part of an internship - but since it's it's open source, it can luckily be modified. Which has to be done due to some bugs (mixing up the bundle parameters for a post, getString, getByteArray). Api documentation could be improved.","created_time":"2011-01-06T05:26:04+0000"},{"id":"504063796_485195138796_3608020","from":{"name":"Renate Hermanns","id":"628810487"},"message":"Wow
, how fast time passes by. Your daughter is nearly grown up ;-).","created_time":"2011-01-06T09:00:23+0000"}],"count":2},"attribution":"Torres"}
I've already posted the question to the FB dev forum, awaiting response.
Related threads:
http://forum.developers.facebook.net/viewtopic.php?id=81365
http://forum.developers.facebook.net/viewtopic.php?id=75984
Facebook Graph API "/userid/feed" returning Blank
Your approach is correct, I've seen the JSON and yes it's missing the second one, I think it's upload app form adroid, try checking the application settings for this app. Or If your trying to retrieve the wall FQL is a much better way
SELECT post_id, actor_id, target_id, message FROM stream WHERE source_id in (SELECT target_id FROM connection WHERE source_id=<uid> AND is_following=1) AND is_hidden = 0
I've been through this, the way Facebook is categorizing their permissions is somehow misleading, for example Publicly available may sounds like Available to everyone on Facebook but apperantly it's not.
Now in your case, if you already authenticated the user, then try using:
/me/feed
I guess this is the only case where access_token is not needed in the URL.
I had a similar problem. But for me, the problem was related to not setting the scope properly on first login (to authorize the app). I posted a similar question and got an answer that worked for me here:
Facebook API how to get all wall items