getting friendlist from facebook graph-api

2024/10/13 14:23:32

I am trying to get user's friend list from facebook Graph-api. So after getting access token when I try to open by urlopen by

https://graph.facebook.com/facebook_id/friends?access_token=authentic_accesstoken

this doesn't give friend_list of person(facebook_id) not even when I open it directly on the browser, at least not the entire list. This is what it shows on the browser

{"data": [{"name": "Face_id_name","id": "facebook_numeric_id"}],"paging": {"next": "https://graph.facebook.com/v2.2/facebook_id/friends?access_token=authentic_accesstoken&limit=25&offset=25&__after_id=enc_Some_encrypted_code"},"summary": {"total_count": 263}
}

In data it doesn't show the entire list and when I use link to paging: next: it doesn't give me anything just total count again.
I am not entirely sure whether my url is right or not.

Answer

You can´t get the friends of ANY user, you can only get the friends of the authorized user and only those who authorized the App too - for privacy reasons. So this is the only correct call:

https://graph.facebook.com/me/friends?access_token=authentic_accesstoken

There is no need to use the ID, because you can only use the ID of the authorized user anyway. So you can just use "me" instead.

More information about the limited friend result can be found in countless other threads, for example: Facebook Graph Api v2.0+ - /me/friends returns empty, or only friends who also use my app

https://en.xdnf.cn/q/118070.html

Related Q&A

Sorting Angularjs ng-repeat by date

I am relatively new to AngularJS. Could use some helpI have a table with the following info<table><tr><th><span ng-click="sortType = first_name; sortReverse = !sortReverse&quo…

Html missing when using View page source

Im trying to extract all the images from a page. I have used Mechanize Urllib and selenium to extract the Html but the part i want to extract is never there. Also when i view the page source im not abl…

Move file to a folder or make a renamed copy if it exists in the destination folder

I have a piece of code i wrote for school:import ossource = "/home/pi/lab" dest = os.environ["HOME"]for file in os.listdir(source):if file.endswith(".c")shutil.move(file,d…

Segmentation fault after removing debug printing

I have a (for me) very weird segmentation error. At first, I thought it was interference between my 4 cores due to openmp, but removing openmp from the equation is not what I want. It turns out that wh…

numpy get 2d array where last dimension is indexed according to a 2d array

I did read on numpy indexing but I didnt find what I was looking for.I have a 288*384 image, where each pixel can have a labelling in [0,15]. It is stored in a 3d (288,384,16)-shaped numpy array im.Wit…

Error sending html email with mailgun python API

I can send text email with the Mailgun python API fine:def send_simple_message(mailtext, filename=""):requests.post("https://api.mailgun.net/v3/mydomain.in/messages",auth=("api…

How to take HTML user input and query it via Python SQL?

Is there a way to take user input from HTML, and use python to run the input through to a SQL database? Does the input need to be parsed? I want the the user to be able to type in a store name, and f…

Reading and taking specific file contents in a list in python

I have a file containing:name: Sam placing: 2 quote: Ill win.name: Jamie placing: 1 quote: Be the best.and I want to read the file through python and append specific contents into a list. I want my fir…

Scipy / ctypes build-config: How to load lib?

These docs have a nice example on how to compile some external C/C++ code and load this using ctypes. This works great with manual compilation (where im controlling the names of my library which later …

Webfaction Django 1.4.1: easy_thumbnails 3.0b – Couldnt get the thumbnail error

I use easy_thumbnails and it works fine on a development machine but in production I get errors like shown below, when I use {% thumbnail photo.image 300x170 %} templatetag. Though can directly browse …