How to grab display picture on Facebook? - facebook

How can I grab someone's display picture on Facebook? I want it for both friends and strangers. Thanks.

You can use the ID if you know it:
https://graph.facebook.com/[Graph-ID]/picture
Source: https://developers.facebook.com/docs/graph-api/reference/v2.2/user/picture
This works with a global ID - meaning, if you know the ID without any App.
If you get the IDs with your App, it´s a bit more complicated. You will only get "App Scoped IDs" nowadays, and you will only get them from friends who authorized your App too. Also, you have to use an Access Token in order to make it work for App Scoped IDs:
https://graph.facebook.com/[Graph-ID]/picture?access_token=xxx
You can also grab different sizes:
https://graph.facebook.com/[Graph-ID]/picture?type=square
(type can be small, normal, large, square)
...and you can specify the size directly:
https://graph.facebook.com/[Graph-ID]/picture?width=121&height=100

Here is the link for the
docs, let me know if you want instructions for specific coding or Programming Langugage on how to do it.

Related

Retrieve Facebook full name and picture from profile url

I'm trying to make a website with text input for facebook profile url and after procceeding, there should be user's name and profile image shown.
I saw something like that here: http://hackfbaccountlive.com/hack_account.php
(No, I'm not making another fb hack.)
I have been trying for a couple of hours now, and I always need to log in, and it's not working as I want.
Can you help me?
You should go into detail about what you're trying to do, as it sounds suspicious (please do not create a hack site). That being said, this all public information that can be fetched with the following calls:
https://graph.facebook.com/[user_id]
https://graph.facebook.com/[user_id]/picture
https://graph.facebook.com/[profile_username]
https://graph.facebook.com/[profile_username]/picture
You can then use either the UID or the profile username to create the profile URL, which is just https://www.facebook.com/[username_or_id]

"Top Posts" depending on facebook likes

I have an idea to create a "top posts" feature to my website, which creates the "top" list depending on how many likes and shares that a post have on facebook.
Users may see how many likes an post has received so far since they only have to ask for a single, defined url. However, the website itself has to be able to query all the links that are tied to itself (which have a predefined url template like website.com/[post-id]) to create the "top" list. Is it possible to do something similar (or achieve the same result in a different way)?
Any ideas on a real workflow about something like this will be appreciated!
this seems like a little but interesting project. I don't know if there is a feature that could get that directly in the way you want, but i did something similar.
First you have the Graph API, with that you can get the Posts of a user using feed, with that every post is telling you how many likes does it have which you can get with POST_ID/likes.
Then you'll have to check for changes in the post periodically comparing its created_time and updated_time.
This could seem very hard, because you have a lot of posts and you have to check them all for updates, but you can use batch_requests so you can check them all at once.
I have made a bookmarklet which shows top posts in the Facebook News Feed as well as Google+, Twitter and Instagram Profiles.
Just add a new bookmark in your bookmarks bar and replace its URL with the following code and save it, then go to the social network website and run it:
javascript:(function(){var s=document.createElement('script');s.src='https://niutech.github.io/topnewsfeed/topnewsfeed.min.js';document.body.appendChild(s);})()
The source code is available on GitHub.

good way to let users search their friends on my fb app

I want to let my users search(not browse) their friend on my fb app. What is the best way?
I have surveyed this issue for hours. I got two ways:
use Graph API:
https://graph.facebook.com/me/friends?access_token=...
by this way, I can get the friends of user as json, and by parsing the json, I can get the one who is the user's target.
However, there are two issues.
First, user need to input the exact name of his/her friend. For example, my app can't find "Steve Jobs" with "Steve" by parsing json.
Second, if the user has a lot of friends, the cost of parsing json may be terrible.
2.
use the searching api:
https://graph.facebook.com/search?q=mark&type=user
by this way, user can get "Steve Jobs" with "steve". However, it is obvious that users may find someone who is not their friend.
I think neither of these ways are ideal enough. Any suggestion?
Thank you sincerely!
How about this: Request dialogs
https://developers.facebook.com/docs/reference/dialogs/requests/
--
For Search Partially, may use indexOf function to check whether this string is match

Getting facebook profile picture

i need to get the facebook profile picture of anyone by passing their id. But i no need to use facebook API or Graph anything else.. Just i need to give the url with that id.. Is it possible to get the profile picture in this way? I tried in google but i didnt get it. If anyone knows this please respond me...
Well, I think the only options available are:
https://graph.facebook.com/[PROFILE_ID]/picture (You can include this URL inside a tag and it will work).
Scrap yourself the page corresponding to the profile, i.e. http://www.facebook.com/profile.php?id=[PROFILE_ID] and get the URL of the picture there.
I would suggest you to use the first one, because it gives you more flexibility about the picture size (?type=small, ?type=thumbnail, etc).
Edit
Keep in mind that this answer is from 2011, and Facebook makes changes in its APIs frequently.
Apart from using Graph API as already mentioned above (https://graph.facebook.com/[PROFILE_ID]/picture), there are a couple more ways:
FlipTop has a service that pulls up all sorts of information on Facebook users, including direct CDN URLs (e.g. https://fbcdn-profile-a.akamaihd.net/hprofile-ak-snc4/275588_504804917_147319_n.jpg) of profile pictures. (Link to API documentation)
Cloudinary has a similar service, but with hosting thrown in the mix. They do require you to open an account, but it's free. Then you can use their CDN URL format to link to any picture like this: http://res.cloudinary.com/[YOUR_ACCOUNT]/image/facebook/[PROFILE_ID].jpg (Read more here)

When should use use "FB.Connect.showShareDialog" instead of "FB.Connect.streamPublish"?

It looks like they do virtually the same thing for simple posts. Do they show up in different place in Facebook? Any ideas?
Using FB.Connect.streamPublish you are allowed to specify attachments (image, flash, mp3), action_links, and a user_message_prompt. The posting to their Profile may be more engaging if you go this route.
The FB.Connect.showShareDialog is mainly just a url that you pass in. Facebook loads that url to get the page title, and see if there are suitable thumbnail images specified on that page.
The main advantage of showShareDialog is that you can ask the users to click on "Send as Message instead" to send the link to specific friends. The default behavior is to "Post to Profile instead".
For basic uses, the two calls can be very similar, but they each have their own distinct capabilities too. I'm finding that I have a need for both in different cases.