How to visuzlize facebook post - facebook

I have a post id (obtained from the Graph API), can I generate a URL which will display this post in Facebook's interface?
Seems there should be something like http://facebook.com/viewpost?postid=6666666666 ...

You want to manually construct a permalink given only the post ID?
The Graph API for a post ID returns the URLs the user should go to to comment on or like the post, assuming the viewing user has permission to do so.
Example:
GET http://graph.facebook.com/19292868552_10150189643478553?access_token={access token here}
Snipped some of the fields of the response, but you're looking for 'actions':
{
"id": "19292868552_10150189643478553",
"from": {
"name": "Facebook Platform",
"category": "Product/service",
"id": "19292868552"
},
// removed fields from response
"actions": [
{
"name": "Comment",
"link": "https://www.facebook.com/19292868552/posts/10150189643478553"
},
{
"name": "Like",
"link": "https://www.facebook.com/19292868552/posts/10150189643478553"
},
{
"name": "Share",
"link": "http://networkedblogs.com/hGWk3?a=share"
}
],
// Snipped rest of response
In general, the format of a permalink seems to be:
https://www.facebook.com/{source id}/posts/{post object id}
(Source ID being the user or page ID where the post is)
You can't definitely reply on that URL format always being the same; the API response should be always accurate though

Related

FB Graph API Response Paging Next contains access_token

Now I am working with Graph API 3.2.
Is there any opportunities to configure within my request went to Graph API to not get back the access token in the end of the response param, called Paging Next?
i.e: here is the documentation.
I just don't want to get back the access token as a plain text in the repsonse, like here:
"feed": {
"data": [
{
"created_time": "2017-12-12T01:24:21+0000",
"message": "This picture of my grandson with Santa",
"id": "{your-user-id}_1809387339093972" // Post ID
},
{
"created_time": "2017-12-11T23:40:17+0000",
"message": ":)",
"id": "{your-user-id}_1809316002434439" // Post ID
},
{
"created_time": "2017-12-11T23:31:38+0000",
"message": "Thought you might enjoy this.",
"id": "{your-user-id}_1809310929101613" // Post ID
}
],
"paging": {
"previous": "https://graph.facebook.com/v3.2/{your-user-id}/feed?format=json&limit=3&since=1542820440&access_token={your-user-access-token}&__paging_token=enc_AdCgj6RSGWTYV7EXj2cFlOWJjbZCq8oI3ogIpLrxPCVK3U8Kad0EgsZA2vri3YKIwl71XGRDJz9C8TgqMeyiu8U5CD&__previous=1",
"next": "https://graph.facebook.com/v3.2/{your-user-id}/feed?format=json&limit=3&access_token={your-user-access-token}&until=1542583212&__paging_token=enc_AdDLmzUgWiLo6oHGCI53S5begiKOfNZBY0affrLMWgheBzfwMA7XSKmgjyNbuZBIptdXc18j1Se0Dm7vEsePh1SoM3"
}
},
"id": "{your-user-id}"
}
Thanks anyway!! :)
It is answered elsewhere: https://stackoverflow.com/a/29900228 but it is good to have a reference to that answer here, too.
The solution that worked for me with various Graph API versions is to pass the token in the Authorization header:
return requests.get(url,
headers={'Authorization': 'Bearer ' + token})
If the token travels in the header, it won't appear in the response anywhere.

Facebook Graph API does not return full post data

I'm using the Facebook Graph API to fetch a public page feed. I created a basic application to get appId and secret. When I make a call to PUBLIC_PAGE_ID/feed I can retrieve the correct list of posts in JSON, but they are missing all the field I need, described in docs, and only have message, created_time and id:
{
"data": [
{
"message": "...",
"created_time": "2015-06-11T07:57:05+0000",
"id": "23X12XXXXXX9836_11XXXXXXXX610XXXX52"
},
...
Why all other data isn't there?
The response to your query: /id/feed is the default response. To access more data, you have to pass a fields parameter with the keyword of data you would like to retrieve.
For example: <id>/feed?fields=id,message,picture,shares
This will return:
{
"data": [
{
"id": "1234567890",
"message": "Message",
"picture": "http://fbcdn.com/xxxxxx.jpg",
"shares": {
"count": 0
}
}
}
What I could figure out is you should submit the app for review with at least one permission what your app still needs and then you will get back every data what you ask in the fields parameter.

Discover SoundCloud user name

I have a SoundCloud client_id that I would like to know the user_id or user name. Actually I have a full link to a track. Is there anyway I can do it?
I think what you're asking is with a track link, find the user_id and username of the uploader of a track.
If you know the full soundcloud.com track URL, hit the /resolve endpoint. For reference, I will be using this URL: https://soundcloud.com/madanofficial/the-police-walking-on-the-moon-j-art-madan-remix
HTTP GET: https://api.soundcloud.com/resolve.json?url=https%3A%2F%2Fsoundcloud.com%2Fmadanofficial%2Fthe-police-walking-on-the-moon-j-art-madan-remix&client_id=[YOUR client_id]
The resulting JSON:
{
"status": "302 - Found",
"location": "https://api.soundcloud.com/tracks/147986343.json?client_id=[YOUR client_id]"
}
When we hit the SoundCloud API again with the /tracks endpoint, just parse the user object that is returned.
"user": {
"id": 44553705,
"kind": "user",
"permalink": "madanofficial",
"username": "Madan.",
"uri": "https://api.soundcloud.com/users/44553705",
"permalink_url": "http://soundcloud.com/madanofficial",
"avatar_url": "https://i1.sndcdn.com/avatars-000098677604-mwg7te-large.jpg?e76cf77"
}

How to get the id of the user that send the request?

In my app there is a MultiFriendSelector to invite friends.
I want that the recipient see in the canvas page the id of the user that has sent the request via MultiFriendSelector.
I need to get the id without using PHP or other server side language, but I can use javascript or fbml for example.
I believe Multifriend selector is a user-user request and a typical request looks the below (from attribute will tell you the request senders information)
{
"id": "REQUEST_OBJECT_ID",
"application": {
"name": "APP_DISPLAY_NAME",
"canvas_name": "APP_NAME", // This is identical to the app namespace
"namespace": "APP_NAMESPACE",
"id": "APP_ID"
},
"from": {
"name": "SENDER_USER_NAME",
"id": "SEND_USER_ID"
},
"message": "Check out this Awesome Request!",
"created_time": "2012-01-24T00:43:22+0000",
"type": "apprequest"
}

How do you retrieve the "Place" field of a Facebook Graph Post object?

I am trying to retrieve the "Place" field of a Facebook Graph Post object from a Facebook friend. After obtaining an access token with the friends_status and read_stream permissions, I request from the Graph API like so:
http://graph.facebook.com/[user_id]_[post_id]
What is returned are some of the fields described in the Graph API docs for Post:
{
"id": "1164358582_2458311174854",
"from": {
"name": "Joe Blo",
"id": "1164358582"
},
"message": "Is pretty bummed today",
"actions": [
{
"name": "Comment",
"link": "http://www.facebook.com/1164358582/posts/2458311174854"
},
{
"name": "Like",
"link": "http://www.facebook.com/1164358582/posts/2458311174854"
}
],
"type": "status",
"application": {
"name": "Facebook for Android",
"id": "350685531721"
},
"created_time": "2011-11-20T03:23:04+0000",
"updated_time": "2011-11-20T12:12:49+0000",
"comments": {
"data": [
{
"id": "1164358582_2458311174852_2962531",
"from": {
"name": "Sue Candy",
"id": "1056617421"
},
"message": "OMG I'm so sorry!!!",
"created_time": "2011-11-20T03:25:06+0000"
}
],
"count": 1
}
}
This is all fine and dandy, except for the fact that when I see this Post within my Facebook stream, it also shows a location accompanying the post:
9 hours ago near El Reno, OK
I expected the El Reno, OK Place object returned as a field within this Post, but I don't see it.
In the Facebook Graph API Explorer, I've tried enabling almost every permission and I am not seeing any difference in the response (no "Place" field returned). Am I going about this incorrectly?
Not 100% sure but I think you can only get the "place" info if it is of type "checkin". I totally get where you are coming from, I wondered about that myself.
https://developers.facebook.com/tools/
Try the Graph API Explorer Tool if you haven't already looked at it.