Facebook FQL or graph API events - facebook

I'm trying to develop an application wich will get all the facebook events and show it on a iphone application.
My question is what is the best way to retrieve all the public facebook events in PHP. I know there is the FQL and the open graph api but with FQL I cannot retrieve just all the public events and I can't seem to find a way to do this.
Can somebody help me with this ?
Kind regards !

Both FQL and the Graph Api work well. Both are great options.
FQL:
FQL may be faster if you want to get all the events from all a user's
friends.
FQL has a method of getting the count of attendees, maybes,
not attendings, and "no replies" directly, without having to count
yourself, which saves LOTS of time when dealing with 20,000 people
concerts etc. [ IF you want to calculate the gender ratios,
unfortunately then this feature wont help you much ]
FQL has a method of determining who was invited by whom, called "inviter" from the "event_member" table, though it appears to be presently broken: Finding who INVITED you :: Facebook FQL Explorer Bug: "Inviter":null
If you are using FQL, you can use "privacy" to determine if the event is public.
SELECT name, venue, location, start_time FROM event WHERE eid in
(SELECT eid FROM event_member WHERE uid=me())
The Graph:
- You used to check "privacy" for the privacy of an event. It is now depreciated and I believe it doesn't matter now, because only the events you have access to will show up.
$JSON = $facebook->api('/'.$target.'/events?fields=name,venue,location,start_time,description,picture.type(large),attending.fields(gender)&since='.time());
TIP: IF your program should show events for one specific region, can use an app's authentication rather than nag a user to log in and approve your app ( unless you have special customizations for each user).

Related

Get friends attending to an event

I searched in the documentation and in the web and didn't find anything about this.
So, when you go to an event page on facebook the list of people who are attending to the event seems to be ordered putting your friends in first place. I want to do that but I can't figure out how.
If I make:
https://graph.facebook.com/<event_id>/attending
I get all people who are attending and it seems it is ordered by when the person clicked on 'attending'.
If I make:
https://graph.facebook.com/<event_id>/attending/<user_id>/friends
I get all friends of the user regardless if they are attending to the event or not.
I tried a lot of connections using Graph API Explorer (https://developers.facebook.com/tools/explorer) like getting the friends of the user and then trying to match them with that event, but could'nt find the solution.
Any help? Thanks in advance.
Better to use FQL in this case. More suited to this type of nested question.
select uid, rsvp_status from event_member where eid = <EVENT_ID> and uid IN (SELECT uid2 from friend where uid1 = me())
That will return all friends of the person logged in who are attending the event you specify.
The accepted answer doesn't work anymore, as facebook no longer allows event attendee requests without one of the event admins' access keys (see Graph api reference). As they also removed the option to access friends' events for privacy reasons, there is currently no way of doing this solely via the Graph API

Some facebook friends' birthdays returning as null but I have the correct API permissions

I'm tring to get my friends' birthdays in my app and some of them are null. I thought that those people don't have a birthday set, but they actually do.
My fql query is:
SELECT uid,name,birthday_date FROM user WHERE uid IN (SELECT uid2 from friend where uid1=me())
The birthdays are also null when I request /me/friends?fields=birthday
My access token has the friends_birthday permission set.
I also tried with birthday instead of birthday_date in the FQL query. Same result.
I imagine that this happens because they opted out somehow, but I don't know how.
Is there an alternate solution to actually get their birthdays from facebook?
It's also possible to remove the ability of apps to access your data when your friends use them, this option will prevent the current session user from seeing some information about their friends via the API, even if that information is accessible on Facebook.com
This setting is in the privacy settings, at https://www.facebook.com/settings/?tab=privacy, under Ads, Apps and Websites -> 'How people bring your info to apps they use' and looks like this:
{edit} you can test this for yourself with test users, it's the most likely reason assuming the birthdays are visible to you in the frontend
These people might have set their Birthdays visible to only themselves or only some restricted friends. This is an option available if we try to edit our Birthday by its side. That can cause it is not available to your query by app.

Linkedin/Facebook Api to get users comment on users out of network update

I am using linkedin api for getting network updates. And I am being able to fetch comments that a user made on either his update or on his 1st degree network updates.
My Question is : Is there any possible way to get the comment a user do on out of network update?
Thanks.
Update : Question for facebook api
It also would be helpful if anyone could lead me to a way to get users recent likes on friends' or non-friends' status/share on facebook. Those are shown on facebook profile page in recent activities block and/or on activity log page of facebook.Although it is possible to get if user likes a page/fan page.
Any help is appreciated.Need help..:-(Answer please...Thanks for feedback!
I'll try to answer your question about the Facebook API.
You can get the current user's likes on status updates with this FQL query:
SELECT object_id FROM like WHERE user_id=me() AND object_type="status"
This will give you a list of the status updates the user has liked, sorted by time, with most recent first. This includes status updates only and not photo or video shares or any other object type. You can modify your query to a different object type by changing the type at the end of the query ("status") to one of these:
photo
album
event
group
note
link
video
application
check-in
review
comment
post
You'll need the
read_stream
user_likes
permissions for this query.
You can read more about the FQL 'like' table here.

Is it possible to do this with fql

Using Facebook's Graph API, I am currently looping through all friends to retrieve their videos, and then present a list of these videos to the user. It obviusly takes a while to do this depending on number of friends,
Is there any way to just say to FQL - give me all videos that I have permsission to view?
Facebook doesn't want applications to be able to "mine data". They don't want applications to be able to collect that much data on anything they want. In most cases an ID must be specified.
User ID
Page ID
Group ID
Event ID
etc...
Even in such a case there is also limitations and multiple calls will have to be made. The limitations themselves are not only limited to accessing data with FQL or the Graph API.
There are also limitations on your access to the API. This is called application throttling and it can be enforced on your application if they find you doing an abnormally large amount of calls to the API. There are also other limitations such as making multiple sequential posts or even duplicate posts to your users.
I'm afraid that the answer is no.
Just playing around with the graph API explorer:
http://developers.facebook.com/tools/explorer?method=GET&path=fql%3Fq%3DSELECT%20vid%2C%20owner%2C%20title%2C%20src%20FROM%20video%20WHERE%20owner%3Dme%28%29
I know that to get a list of my friends I can do:
SELECT uid2 FROM friend WHERE uid1=me()
I then updated the video query to:
http://developers.facebook.com/tools/explorer?method=GET&path=fql%3Fq%3DSELECT%20vid%2C%20owner%2C%20title%2C%20src%20FROM%20video%20WHERE%20owner%20IN%20%28SELECT%20uid2%20FROM%20friend%20WHERE%20uid1%3Dme%28%29%29
And now I get a paginated list of all videos belonging to my friends. This one query is certainly better than pounding the API to death with multiple calls. :)

How to get friends in order of number of mutual friends?

I am developing a Facebook application. I want to know how I can get friends in the order of number of mutual friends.
Is it possible with FQL or any other method?
Update
I can't find a way to do it in one request using graph API
but it can be done in Ruby by getting friends list then sending request for each friend using User context like this example
Original answer
Here is the FQL query to be used Which is working only for api versions < v2.1
SELECT uid, mutual_friend_count from user where uid in (SELECT uid2 FROM friend WHERE uid1=me()) ORDER BY mutual_friend_count desc
you can try it in the explorer
https://developers.facebook.com/tools/explorer?method=GET&path=fql%3Fq%3DSELECT%20uid%2C%20mutual_friend_count%2C%20friend_count%20from%20user%20where%20uid%20in%20%28SELECT%20uid2%20FROM%20friend%20WHERE%20uid1%3Dme%28%29%29%20ORDER%20BY%20mutual_friend_count%20desc
Theoretically, you can get a list of a user's friends using:
$friendsOfFriend = $facebook->api('/'.$yourFriendsFacebookId.'/friends');
Then you can check each of the result to see if they are your friend too.
$isMyFriend = $facebook->api('/me/friends/'.$someonesFacebookId);
... and keep a track of the count.
However my test didn't return any result yet. I attempted to get the friends of some of my facebook friends but it returns an exception: Can't lookup all friends of {friend's_facebook_ID}. Can only lookup for the logged in user {my_facebook_ID}, or friends of the logged in user with the appropriate permission. So there might be permission issue here.
I don't think mutual friends are available via FQL so you would have to do this the hard: calling the graph api in a loop for each friend and getting a count of mutual friends. The graph api method is: /me/mutualfriends/yourFriendsId and you could do 20 batch requests at a time to help speed this up. If you can find a way to do this with FQL, that would be your fastest route.
This is only a partial answer as they are not all in one place, still haven't found a way to get them on one page yet, but it is a start, could be run in a loop programmatically through your friend list...
https://www.facebook.com/browse/mutual_friends/?uid=xxxxxxxxxxxx
because if you don't give a uid it returns an error... I was just trying to get a list of all my friends on one pagem, but no dice. ridonculous.