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
Related
How can I query facebook's graph API to retrieve all user's likes (not only pages but also photos and others)?
For instance, how could I get all the pictures a user has liked? Using facebook's search bar you can find them easily by clicking on "photos has liked".
I wrote a script that scrapes the page content and does that but it's not very efficient.
I have recently come accross a similar problem, maybe this helps you solve it.
https://graph.facebook.com/v2.5/{page_id}/feed?fields=likes.limit(1).summary(true)&since={start_date}&until={end_date}&access_token={access_token}
This will give you a list of all posts that received likes during the specified time period. If you manage to write a code summing up the following JSON path you got your sum for "all user's likes":
data[0].likes.summary.total_count
Not entirely sure is this is exactly what you were searching for, hope it helps you though - and if not you, someone else.
As for likes you can also use the same way to extract Shares and Comments:
Shares
https://graph.facebook.com/v2.5/{page_id}/feed?fields=shares&since={start_date}&until={end_date}&access_token=
Comments
https://graph.facebook.com/v2.5/{page_id}/feed?fields=comments.limit(1).summary(true)&since={start_date}&until={end_date}&access_token=
Best regards
There isn't to my knowledge any way to get this from the API without grabbing every type of response from the API and then sorting through for likes. Facebook search bar uses an internal API different from the Graph API.
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.
Our client would like to have a simple quiz that everyone can take, and if the user want, they can share the result on Facebook. Pretty much similar like this: http://www.whichblankareyou.com/q/which-alcoholic-drink-are-you
The only thing is; the client thought of randomly giving away a price to one of the users who shared their results on Facebook, this to encourage more people to really share their result (and thus generating more 'buzz' on Facebook about it)
Is it possible to do this? and if so: how ?
After your user posts a story a post_id is returned by the facebook and this is of the form-
userid_postid
So, you can fetch the id before _ and that will be the id of the user who shared the story.
Hope that helps! :)
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.
PART A -
There are many many questions like this, but none of them seem to provide a working solution. I want to get a list of friends who clicked the Facebook "Like" button on an external site.
NOTE: This is NOT for a Facebook page. In this case, I know I can query the page_fan table.
To get the list of Facebook page-likes for example, I can use the url_like table. I guess I just want a way to invert this table. I know I cannot get a list of ALL people that liked a link due to privacy concerns, but I want a list of my friends alone - which should be fine.
I know facebook does this internally every time I see a Facebook Like button... right below that there is statistics about my friends that also like the same link. How do I get this using FQL?
PART B
Equivalently, how do I get a list of friends that shared a specific URL as a link? I cannot search the link table by url because that is not indexed. Also, the link_id is not the same as the Open Graph ID of the URL.
I tried select link_id from link where url="http://urladdress.com/a/b.html" and owner in (select uid2 from friend where uid1=me()) but that neither throws an error not returns anything... just stalls.
Part A: you can't.
Part B: you can't the way you are trying. You might be able to get the feed for every one of the users friends and look for that url from their feed, but it will be painfully slow.
Lots of people would like to know this but Facebook is (rightfully so) not giving this information out. That is why you see lots of questions regarding it but no working solutions.
You could possibly look into the read_insights permission. You might not be able to get the exact information about "likes" (yet)... but you will be able to get other possibly useful information.