Is there a way to get friends with relationship_status equals Married using Graph API?
I did it using FQL, but some fields aren't equals and I have problems using RestFB with these fields like birthday which have different behaviors using Graph API and FQL.
FQL code do get married friends
SELECT uid, name, relationship_status FROM user WHERE (uid = MY_ID OR uid IN (SELECT uid2 FROM friend WHERE uid1 = MY_ID)) AND relationship_status='Married'
I wanna to do the same with Graph API
Graph API is more clean I think too.
Thanks
You have the exact query to get all married friends.
Just you have to do is call this FQL query using GRAPH API.
See the following blog for more details on how to call an FQL using GRAPH API.
http://developers.facebook.com/blog/post/579/
Also please read my answer to this question to just to fix any possible errors when using 'file_get_contents' in your code (as in the example of the FB blog post)
try this..
https://graph.facebook.com/fql?q=SELECT uid, name, relationship_status FROM user WHERE (uid = me() OR uid IN (SELECT uid2 FROM friend WHERE uid1 = me())) AND relationship_status='Married'.
Related
Is there any way using the graph api to search all users but to list matching friends first?
If I search using this it requires a user access_token. So it knows who I am. So why does it (almost seem like its) avoiding displaying my friends? Why doesn't it return my friends that match the query first and then after that, anyone else?
Is there a way to make it mimic that functionality?
I also wondered the same thing as the OP. The only thing I've been able to come up with in my research is using FQL...The problem with FQL? After v 2.0 of the Facebook API it will no longer be available--and the version after that it will probably be deprecated.
But in the interest of getting a working solution NOW, I found this SO (third answer down): searching friends using facebook graph api
Here's the example that worked for me:
select uid, name, sex
from user
where uid in (SELECT uid2 FROM friend WHERE uid1 = me())
and (strpos(lower(name),'Jack')>=0 OR strpos(name,'Jack')>=0)
Also, if you want their pic use:
select uid, name, sex, pic_small
from user
where uid in (SELECT uid2 FROM friend WHERE uid1 = me())
and (strpos(lower(name),'Jack')>=0 OR strpos(name,'Jack')>=0)
(I'm getting their small pic but documentation for other sizes of the pic is found here: https://developers.facebook.com/docs/reference/fql/user/)
Is it possible that I can get ALL the posts from my friends via API in facebook? I mean All because I need all of them to search if it contains a keywork. Is it possible?
You can search an individual user's News Feed, restricted to that user's friends, by adding a q argument to the home connection URL:
News Feed: https://graph.facebook.com/me/home?q={KEY}
https://graph.facebook.com/me/home?q={QUERY}&access_token={ACCESS_TOKEN}
Eg: https://graph.facebook.com/me/home?q=facebook&access_token=######
You can do that by using the following FQL query:
SELECT post_id, message FROM stream WHERE source_id IN
(SELECT uid2 FROM friend WHERE uid1 = me()) LIMIT 5000
But you need a valid Access Token with an extended read_stream permission. For testing your FQL queries, you can use Graph API Explorer.
I'm using play framework to create a facebook application. I'm kinda stucked at some point. With Graph Api i can't take a list of friends who use my application. What i want to say is for example:
A is using my application.
B is using my application too and B is a friend of A.
When A is using my application, I want A to see B is also using this application.
Simply I want to get list of friends using same application.
How would i do that with Graph Api?
There is a field called "is_app_user" on the user table that you could run a FQL query against. The query would be something like:
select uid, name
from user
where is_app_user = 1
and uid in (SELECT uid2 FROM friend WHERE uid1 = me())
The graph url for that would be like this (remember to add an access token):
https://api.facebook.com/method/fql.query?query=select uid, name from user where is_app_user = 1 and uid in (SELECT uid2 FROM friend WHERE uid1 = me())&access_token=...
With Friend A's access token do a Post to me/friends to get the list of friends. See if Friend B is on the list. See: http://developers.facebook.com/docs/reference/api/user/
Is there any fql statements allowed by facebook that helps to fetch contents of this page through an application interface: http://www.facebook.com/posted.php I know the links table returns the posted item for a logged in user (http://developers.facebook.com/docs/reference/fql/links). I need the same but for the logged-in user's friends.
Thanks.
you can use Fql query or Graph API to get your friends data.
Sometimes you will not get all information from the graph like birthdate of your friends but yes you can use fql queries to solve your probs.
here is an exmple for you.
create first facbook object and the use it.
$query = "SELECT uid, first_name, last_name, birthday_date, sex, pic_square, current_location, hometown_location FROM user WHERE uid IN (SELECT uid2 FROM friend WHERE uid1 = me()) AND birthday_date != 0 ORDER BY birthday_date";
Regards,
Archit.
You can do this through an FQL query - though you may need to use multiple queries if you require more information about the friend who posted the link:
select title, owner from link where owner in (select uid2 from friend where uid1 = me() limit 100)
You may want to limit the number of friends (or even the links themselves) as this can be a costly query
I've been playing around the Facebook Graph API for a while now.
I'm trying to get the list of friends using https://graph.facebook.com/me/friends.
While it's working fine, the results are ordered by Id. Is there a way to get them ordered by name, or do I have to reorder them manually via my application layer?
Thanks!
I don't think there is a way of ordering Graph API results, but you can order FQL results. Something like:
SELECT name, uid FROM user WHERE uid IN (SELECT uid2 FROM friend WHERE uid1 = $current_user_id) ORDER BY name