Actual Contact Finder using the Social Graph API
on June 05, 2008This week I suddenly realized that one month ago, we implemented XFN on iknow.co.jp – the startup I’m working for. I almost completely forgot about this and I needed some 20%-google-time distraction from my day to day tasks. So I thought about doing a quick search and jacking in a simple friend finder that uses the Social Graph API. A friend finder meaning: you input your SNS-X username and you will get all SNS-X usernames that are your friends on SNS-Y, SNS-Z.

To my amazement I couldn’t find any straightforward pieces of code actually doing this. All I could find was the usual pretty printed JSON outputs. So I rolled up my sleeves and did some Javascript hacking myself.
I wrote a Javascript class that you can easily use to enable a friend-finder on your own SNS site. Basically there are two main parameters:- A regular expression determining the profile URL structure of an SNS
- The profile URL of the person to recommend friends to, eg: twitter.com/dominiek
The code should be fully customizable for your own SNS, feel free to use it however you want: (don’t forget to fetch socialgraph.js)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
// callback: function contact_found(username, is_new, on_site_name, on_profile_url) { // a user on this site was found and is a friend on_profile_url // this is also where the is_friend_already? check goes } // callback: function contact_search_status(percentage) { // progress report, might take a while to query everything } // setup regexp for this SNS var site_regexp = new RegExp(/http:\/\/www\.iknow\.co\.jp\/user\/([^\/]+)/); // setup library and pass in callbacks (contact_search_status is optional) var social_graph = new SocialGraph(site_regexp, contact_found, contact_search_status); // recommend for user dominiek social_graph.contacts_for('http://www.iknow.co.jp/user/dominiek'); |
When doing a search, about 8 to 40 calls are done to the SocialGraph API to walk through all the data. That’s one of the reasons why I really love JSON – all of this stuff is done on the client side.
Please note that any profile URL used in gathering friends data has to be referred to or must refer some other XFN relationships. The more ‘me’ and ‘contact’ links, the better the results will be. iknow.co.jp is actually a very good example of this.
Note: a fellow developer (Zev Blut) pointed out to me that instead of fooling around with too many regular expressions it’s good to look into Node Canonicalization
ミクシィでiKnow日記が見れるよ!
on December 17, 2007iKnowの日記を自分のミクシィ日記に設定することが出来ます。
Did you know you can set iKnow as a journal on Mixi?
ミクシィで設定変更をクリックして下さい。
Click on settings when logged into your Mixi account.
設定変更のページで「日記・ブログの選択」と「日記・ブログのURL」と「RSSのURL」を入力して下さい。
On the settings page, fill in “blog selection”, “blog URL” and “RSS URL”.
「dominiekth」は私のiKnowユーザーネーム。
Replace “dominiekth” with your own username.
That’s it!

Dominiek.com, Now with Extra Data
on December 02, 2007This week, a cool Japanese coder reminded me of the importance of blogging: it is the best resume out there. Also, it is you permanent footstep into the eternal virtual world.
This week I have been playing around with the JSON feeds that twitter offers. This is how I got the 'What am I doing now?' in the top here. I also did it for delicious. I am very excited about these JSON widgets and I will soon start coding and blogging more about it. Too bad last.fm doesn't have them yet.
Soon, I will also start blogging about the project I'm consulting for: