How To User Fetch Friends Data Using Graph API - facebook

What i Need:
i need to fetch my friends like email ,id , name .
i have tried using https://developers.facebook.com/tools/explorer/1456/?method=GET&path=me&version=v2.1.
url is like graph.facebook.com/v2.1/me .
data
{
"id": "77",
"email": "af55#gmail.com",
"first_name": "Mo",
"gender": "male",
"interested_in": [
"female"
],
"last_name": "f",
"link": "https://www.facebook.com/app_scoped_user_id/777/",
"locale": "en_GB",
"name": "singh",
"timezone": 5.5,
"updated_time": "2014-08-18T05:34:55+0000",
"verified": true
}
but making call graph.facebook.com/v2.1/user
Error
{
"error": {
"message": "(#803) Cannot query users by their username (user)",
"type": "OAuthException",
"code": 803
}
}
i have refer the url https://developers.facebook.com/docs/graph-api/reference/v2.1/user.
i have tried to solve by go ->getACEESS TOKEN->check on permissions->email->user_friends.
but still i cannot fetch url through user.
making call with me/friends
{
"data": [
{
"name": "Ashwani Gaur",
"id": "62036"
},
{
"name": "Shobhit Puri",
"id": "131"
},
{
"name": "Rahul Raman",
"id": "10007"
},
{
"name": "Piyush Agarwal",
"id": "800899"
},
{
"name": "Neeraj Yadav",
"id": "10000"
}
],
"paging": {
"next": "https://graph.facebook.com/v2.1/777009872366669/friends?limit=5000&offset=5000&__after_id=enc_AeytV0frT0k1mTj0ZfZRTxPsdSP3TVT_Qd-I1Aoc8vA8YseN4Rr8Vg5n6RgECxsd6RXaVNL8fJ0iaI79qEW7K8nw"
},
"summary": {
"total_count": 383
}
}
i need id, name, email, friend personal_info.

Since April 2014 (v2.0), there are no friend permissions anymore and it´s not possible to get user data from people who don´t use the App. See the changelog for more information: https://developers.facebook.com/docs/apps/changelog
The docs are a bit misleading, you can only use /me to get data of the user who is logged in at the moment.
Update:
By requesting /me/friends, you get all the friends using the App. But as i said in my first sentence, there are no friend permissions anymore. You will only get ID and name of your friends, nothing else. Even if your friend authorized your App, you can ONLY get more data with his own session and by calling /me. The email permission only gives you access to the email of the user who is logged in, not access to the emails of all his friends, of course.
You can only store the email after authorizing a user, that is the only way for other users to get the email of his friends - at least the ones who authorized your App too.

Related

Unsupported get request. Object with ID '{USER_ID}' does not exist, cannot be loaded due to missing permissions, or does not support this operation

I am getting this from Facebook webhook. I am trying to get the sender's name and profile picture.
<pre>
{
"object": "page",
"entry": [
{
"id": "172916740162087",
"time": 1609667491,
"changes": [
{
"value": {
"from": {
"id": "2529118547136023",
"name": "Md Abid Hasan Nayem"
},
"post": {
"status_type": "added_photos",
"is_published": true,
"updated_time": "2021-01-03T09:51:29+0000",
"permalink_url": "https://www.facebook.com/CodeWareLTD/posts/851154192338335",
"promotion_status": "inactive",
"id": "172916740162087_851154192338335"
},
"message": "Happy new year",
"post_id": "172916740162087_851154192338335",
"comment_id": "851154192338335_853191445467943",
"created_time": 1609667489,
"item": "comment",
"parent_id": "172916740162087_851154192338335",
"verb": "add"
},
"field": "feed"
}
]
}
]
}
</pre>
When I am sending request with the user id /{USER_ID}?access_token=token then it's returning this error.
Whereas I have all the required permissions approved.
<pre>
{
"error": {
"message": "(#3) Application does not have the capability to make this API call.",
"type": "OAuthException",
"code": 3,
"fbtrace_id": "ABtpgYvcMuaA_jQcW8Fdi3M"
}
}
</pre>
I opened a bug report, but they told me it's ok as per the current Facebook system design. But
still, I'm unable to get the user's first name, last name, and profile picture.
Bug Report Link: https://developers.facebook.com/support/bugs/887826828623849/.
Please, help me to get the exact API to get the sender's name & profile picture.
my currently successfully reviewed permissions are:
email,
pages_manage_metadata,
pages_read_engagement,
pages_show_list,
pages_messaging,
pages_read_user_content,
public_profile,
pages_manage_engagement,
pages_manage_posts

Facebook Graph Search Error while searching "Event"

This is embarrassing, but I am at my wits end. While performing a very simple search for "Events" using fb Graph Search, I get the following error:
{
"error": {
"message": "(#200) Must have a valid access_token to access this endpoint",
"type": "OAuthException",
"code": 200
}}
This is the code I execute:
https://graph.facebook.com/search?q=conference&type=event&limit=1&access_token=XXXXXXXXXX|XXXXXXXXXX
It works JUST FINE for any other type of search - with the same access token for example:
https://graph.facebook.com/search?q=conference&type=place&limit=1&access_token=XXXXXXXXXX|XXXXXXXXXX
I get the following result:
{
"data": [
{
"category": "Local business",
"category_list": [
{
"id": "164243073639257",
"name": "Hotel"
}
],
"location": {
"street": "Langelaan 3",
"city": "Noordwijk",
"state": "",
"country": "Netherlands",
"zip": "2211XT",
"latitude": 52.251963727407,
"longitude": 4.4722281054509
},
"name": "NH Conference Centre Leeuwenhorst",
"id": "165032770219308"
}
],
"paging": {
"next": "https://graph.facebook.com/search?limit=1&type=place&access_token=XXXXXXXX|XXXXXXXXX&offset=1&__after_id=165032770219308"
}
}
At this point, I am out of ideas.
Facebook recently changed things in their API, Search was one of those things. You can only do this kind of search on Places and Pages now. To search events, you need an app access token. See this blog post: https://developers.facebook.com/blog/post/2013/04/03/platform-updates--operation-developer-love/
Fixed! I am now able to search for events by using an App Token generated using the new api. Thank everyone for your help

Permissions to get comments of post user is tagged in on facebook

I'm attempting to do some analysis of a user's Facebook data, so I'm attempting to collect as much as possible. Using the Facebook graph api, which permissions do I need to request in order to get the comments for a post the user is tagged in. If the post is on the user's wall, it isn't a problem, but if the user is tagged in a post on a friend's wall no comments are there, and the count is set to 0.
I'm making a request to //feed with what I believe to be a valid access token from my application. However, using the graph explorer tool from Facebook the same situation happens. I assume the problem is a permission I am missing, but can't seem to figure out which one I should add.
I'm currently requesting the following permissions:
friends_photos
friends_likes
friends_checkins
friends_status
user_photos
user_likes
user_checkins
user_status
read_mailbox
read_stream
{
"id": REDACTED,
"from": {
"name": REDACTED,
"id": REDACTED
},
"to": {
"data": [
{
"name": REDACTED,
"id": REDACTED
}
]
},
"message": REDACTED,
"message_tags": {
"121": [
{
"id": REDACTED,
"name": REDACTED,
"type": "user",
"offset": 121,
"length": 11
}
]
},
"privacy": {
"value": ""
},
"type": "status",
"created_time": "2013-03-13T14:25:44+0000",
"updated_time": "2013-03-13T14:25:44+0000",
"comments": {
"count": 0
}

how to query facebook user's email using graph api?

i need help to get facebook user's email. here's what I did.
https://graph.facebook.com/me?scope=email&access_token=xxxxxxxxxxxxxxxx
the result I got back has no email in it.
{
"id": "7027110",
"name": "John Mike",
"first_name": "John",
"last_name": "Mike",
"link": "http://www.facebook.com/john.mike",
"username": "john.mike",
"location": {
"id": "11241875545",
"name": "Oakland, New Jersey"
},
"gender": "male",
"timezone": -5,
"locale": "en_US",
"verified": true,
"updated_time": "2011-12-07T16:53:47+0000"
}
also tried to change scope=email to fields=email, still does not work. whats missing, please help me out
You can get user email like this:
https://graph.facebook.com/v2.5/me?fields=id,name,email
more detail go here
Did you obtain the email extended permission from the user? You can check which permissions your access token has been granted with a call to /me/permissions
The user has to authorize you to get this information first. If it were possible, we would be receiving 100 times more spam than we already receive.
This Facebook tool can help you.

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.