English 中文(简体)
Getting a friend count from Facebook (possibly using api)
原标题:

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:

  1. Set up an application
  2. Implement Facebook Connect on your site
  3. Get users of your site to log in with Connect. (You can t ask for their username/password.)
  4. 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.





相关问题
Brute-force/DoS prevention in PHP [closed]

I am trying to write a script to prevent brute-force login attempts in a website I m building. The logic goes something like this: User sends login information. Check if username and password is ...

please can anyone check this while loop and if condition

<?php $con=mysql_connect("localhost","mts","mts"); if(!con) { die( unable to connect . mysql_error()); } mysql_select_db("mts",$con); /* date_default_timezone_set ("Asia/Calcutta"); $date = ...

定值美元

如何确认来自正确来源的数字。

Generating a drop down list of timezones with PHP

Most sites need some way to show the dates on the site in the users preferred timezone. Below are two lists that I found and then one method using the built in PHP DateTime class in PHP 5. I need ...

Text as watermarking in PHP

I want to create text as a watermark for an image. the water mark should have the following properties front: Impact color: white opacity: 31% Font style: regular, bold Bevel and Emboss size: 30 ...

How does php cast boolean variables?

How does php cast boolean variables? I was trying to save a boolean value to an array: $result["Users"]["is_login"] = true; but when I use debug the is_login value is blank. and when I do ...

热门标签