My manager gave me a simple(tough for me) assignment to learn..
Problem: Write a command line app using your favourite language that accepts 2 facebook ids and return a list of common friends between the 2 ids.
I couldn't! I could make a program that list my friends but not others because it's private information and it requires others to allow my application blah blah..
So I gave a try for twitter and I SUCCESSFULLY DID IT! ;) Because following and followers list are public in twitter.
Check out the script and screenshot
Script
#!/bin/bash
link1='https://api.twitter.com/1/friends/ids.json?screen_name='$1
link2='https://api.twitter.com/1/friends/ids.json?screen_name='$2
curl $link1 > .fol.tmp
curl $link2 > .fol2.tmp
cat .fol.tmp | sed 's/.*\[\([0-9,]*\)\].*/\1/' | sed 's/,/\n/g' | sort > .ids.tmp
cat .fol2.tmp | sed 's/.*\[\([0-9,]*\)\].*/\1/' | sed 's/,/\n/g' | sort > .ids2.tmp
#comm -12 .ids.tmp .ids2.tmp | tr '\n' ',' | sed 's/,$//' > .comids.tmp
#comm -12 is same as grep -xFf :)
grep -xFf .ids.tmp .ids2.tmp | tr '\n' ',' | sed 's/,$//' > .comids.tmp
comids=`cat .comids.tmp`
comidlink='https://api.twitter.com/1/users/lookup.json?user_id='$comids
curl $comidlink > .lookup.tmp
cat .lookup.tmp | tr ',' '\n' | grep '"name"' | sed 's/.*:\"\([^\"]*\)\"/\1/g'
rm .fol.tmp .fol2.tmp .ids.tmp .ids2.tmp .comids.tmp .lookup.tmp
Note: I'm an amateur programmer. This code may not be the most efficient but it does the job well.
Screenshot: