Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get Facebook user's profile picture prior to authenticating app

Summary:

I am working on a website that connects to Facebook through the Graph API. I was asked whether I can get a user's profile picture if they are already logged into Facebook, but prior to the user authenticating the app. Is this possible?

EDIT: I know you can get people's profile picture by going to http://graph.facebook.com/USERNAME_OR_USERID/picture?type=large, but would I be able to get a user's username or ID if they are logged into Facebook, but have not authorized my app?


Details:

According to the Facebook API User documentation, you can get their Facebook ID without an access_token, and I know if you go directly to a user's /me URL you can see their basic information. With the Facebook ID, I can grab their profile pic.

However, when I try to call it from the website using the following code, I get an OAuthException error.

FB.api('/me', function(response) {
    console.log(response);
});

I'm guessing that they have to authenticate the app, but I'm looking to see if I may have missed a way of getting their profile pic.

Thanks for your help!

like image 558
Paul Sham Avatar asked Dec 15 '11 23:12

Paul Sham


People also ask

Is the Facebook API free?

The Graph API is free to use, for all applicable use cases.

What is PSID Facebook Messenger?

PSID is a page-scoped ID for every contact in your Contacts that Facebook creates to handle different communication channels. It's common for a business to use multiple channels to communicate with its customers, e.g., a website, a mobile app, and Messenger.


2 Answers

You can get everyone's Facebook profile picture without authentication.

You just call http://graph.facebook.com/USERID/picture?type=large. This URL redirects you to image URL.

Edit: Querying by username is not allowed anymore, so I updated USERNAME_OR_USERID as USERID.

like image 194
Hüseyin Cevizci Avatar answered Sep 24 '22 08:09

Hüseyin Cevizci


yes you can get..

http://graph.facebook.com/naseer.panhwer/picture?type=normal
http://graph.facebook.com/naseer.panhwer/picture?type=small
http://graph.facebook.com/naseer.panhwer/picture?type=large
like image 23
Naseer Panhwer Avatar answered Sep 23 '22 08:09

Naseer Panhwer