I'm used to working with Twitter, where friend/follower totals are available in a simple XML request.
My goal is a simple "enter your username/user id, and display your friends count".
Is there something like this for Facebook? From what I gather, I'll have to make an application, and have anyone who wants to grab their friends total actually install that app from within their own Facebook profile.
Anyone have any experience with this?
You can get friend count by fql easily.
There is a friend_count field against the user table that you can query.
SELECT friend_count FROM user WHERE uid = me();
https://graph.facebook.com/fql?q=SELECT friend_count FROM user WHERE uid={any id}
You do need to set up an application, but it'll work as a Connect app - meaning that users won't have to access it through their Facebook profile at all. In broad terms you'll need to:
Set up an application
Implement Facebook Connect on
your site
Get users of your site to log in
with Connect. (You can't ask for
their username/password.)
Make a Friends.get call to the
API, probably with the JavaScript
client library (although there
are server-side ways you can do it)
Facebook provides an API for developers so you can grab information from Facebook. Check it out at the provided link.
Edit: From your tags, it looks like you are already familiar with the Facebook API. You can use the API with external applications or webpages - it doesn't necessarily need to be used within a Facebook app, if that is what you are asking.
Related
I need to be able to consolidate all the likes from users that use my Facebook app into an Excel or .csv file. I can have the user authenticate within my Facebook app, but is there a way to see the likes for all users of an app using Open Graph or some other Facebook tool? I'm certain that someone else must have had this problem, and I'm hoping that one of you can help me out!
I've been trying to run FQL queries to bring up likes, but don't have any experience with PHP so it has been miserable so far. Any ideas?
There's no way to retrieve a list of users of your app - you'll need to manually build that as users authorise the app see this question for more information
Assuming you have permission to access a user's likes connection - access /USER_ID/likes and parse the response, saving it to a file in accordance with whatever language you're using's syntax (google is your friend here)
Note that your use of the data is subject to Facebook's policies and user's consent in accordance with your privacy policy and sharing it with third parties may be illegal (i am not a lawyer, this is not official advice, etc etc)
Here is the problem with that the application type does not have a like connection. Application Object GraphAPI This is inconvenient when you are looking to gather data on the users that like it.
OR were you talking about the likes endpoint of the user object? That you can gather but I dont think it is what you are looking for. It is shown here Graph Explorer Example - user's likes
I want to get facebook friends Id of a specific facebook user. how can i do this?
in detail : I have a server, and form a mobile I'll send a facebook id of a user to that server. accoding to that facebook id I want to get facebook ids of friends of that user. (this should do from server) please any one guide me to do that.
answer = for this we should have access token.
Sounds like facebook wouldn't like that :)
You could scan profile.php?id=&sk=friends and parse the output for the ids.
But I'm sure the habe some fancy Ajax running giving you an easier method.
Have you checked their API? https://developers.facebook.com/docs/reference/api/FriendList/
But you need permissions for that.
I've been building a web app that uses facebook integration for easier registration/login and notifications for the users. However, for the notifications I want to be able to post to a users facebook wall when something happens on our site.
Really I see two possible problems with doing this. First being that the user will most likely not be logged in to our website when the notification needs to happen. Second I have not found a way to post to the feed using any identity other than the current logged in user.
So to reiterate exactly what I'm trying to do. When some action takes place on my site involving Bob, I want the websites application to post on Bobs wall notifying him of the action as if the application is one of Bobs friends. From some of the things I've seen while researching this, it seems as if facebook might not treat applications like users and I might have to go through a page to accomplish what I want. But really I'm ok with that.
What you need to do is to ask for the offline_access permission. Then you can store their graph id property after they login/authorize to your site's database. Then you just post to that graph id instead of instead of /me. In your case you would then POST a request to the "$user_graph_id/feed" endpoint with whatever parameters you usually have.
How do I get parse information about the App that I own? that is to say, that I know the App Id, secret Id and all the relevant information. Does the API provide a way to, say, get the number of users using my app? etc.
It is possible, you need to use FQL and query this table.
Facebook Connect
I have spent a few weeks putting together a basic web site which uses Facebook connect as authentication.
I have studied 'theRunAround', the provided example application. However the code is convoluted and uses a large number of files and classes, most of which have a lot of functionality that I have no need for. I have also had a good read of the documentation.
My code works almost all the time. However, occasionally I receive strange, unpredictable errors.
Required Features
Check if user is already logged in to Facebook, if so, retrieve the fb_uid, name, profile pic
Return a list of friends which have also connected to this application
Are there any tutorials, better than the ones provided by Facebook regarding such simple functionality?
I wrote my own library to work with Facebook Connect as I found the one provided to be very lacking.
I can't provide the code as it is company code, but here's a breakdown of what I needed to do. Hopefully you can use it and fill in the blanks easily yourself.
In your application settings, configure the "Connect" tab. The "Connect URL" in my case is the root folder where my xd_receiver.htm file is. Also, under "Advanced" I marked my app as a Web Application.
Put your xd_receiver.htm file in the root folder specified above. There is a ton of documentation on xd_receiver.htm out there. This is what facebook hits when the user logs in. It will write cookies to their browser which your application can read in later to do authentication.
The cookies Facebook sets are in the format of _ where APIKEY is your apps API key and is the name of the cookie. You'll need the _session_key cookie to make further API calls. If this cookie is not set, you need to show the login button as desscribed in steps 4 - 6. Otherwise skip to step 7.
You need to load in the Facebook javascript file on your page that you will have the FB login button. ==> http://static.ak.connect.facebook.com/js/api_lib/v0.4/FeatureLoader.js.php
To show the FB login button, use:
The Facebook JS will automatically render a facebook login button for you. It will trigger the "facebook_onlogin" method that you shall define once the user is logged in so you can do something after they login.
Right below the above markup, you need to call the FB init javascript to have it render the button:
FB.init('YOUR API KEY HERE', 'ABSOLUTE PATH TO YOUR XD_RECEIVER.HTM FILE HERE');
Use the session_key as set in the cookie to make any API calls. How to make API calls is well documented.
Hope this helps.
I have recently added a friend notification feature to Cogenuity using the facebook connect technology.
First, you need to create the facebook object in your php code. I am assuming that you have already done the facebook application registration goodness. I found a lot of the parts to facebook connect not to work but what did work was this.
$user = $facebook->require_login();
I found that the FQL parts worked pretty good.
$query = "select uid1 from friend where uid2 = {$user}";
$results = $facebook->api_client->fql_query($query);
I used this FQL query which may serve your needs.
$query = "SELECT name, pic_square, status, about_me FROM user WHERE uid = {$uid}";
$results = $facebook->api_client->fql_query($query);
As does the notification_send method.
$facebook->api_client->notifications_send($notifyTarget, $intro, 'user_to_user');
I hope this helps.