Get Facebook friends working in same company
Problem :
Need to find common friends working in the same companies with Facebook.
Solution :
Use FQL to extract friends' work history.
FQL : select uid,name,work_history from user where uid in (SELECT uid2 FROM friend WHERE uid1=me())
You can play around your query with Facebook Graph API Explorer to see if the extracted result is suitable for your needs. However, bear in mind that the FQL result will not be complete. Only partial result of your total friends.
Below is a PHP code fragment that I used to extract friends work history data
if (($user) && ($data['fid'])) { //ok, the user exist, we find out the common friends
// the permission granted by the Facebook user will determine the behaviour of the access token
// if no friends_work_history permission is granted, then the facebook user cannot see their friends working in which companies
$access_token = $this->facebook->getAccessToken();
$query = 'select uid,name,work_history from user where uid in (SELECT uid2 FROM friend WHERE uid1=me())';
$file = file_get_contents('https://graph.facebook.com/fql?q=' . urlencode($query) . '&access_token=' . $access_token);
$jsonFriends = json_decode($file, true);
$Friendsincompany = $jsonFriends['data'];
$data['Friendsincompany'] = $Friendsincompany;
}
Hope you will find this tutorial useful and assist your development work.
See also : Facebook : Getting the friends list with PHP return JSON format
By Adam Ng
IF you gain some knowledge or the information here solved your programming problem. Please consider donating to the less fortunate or some charities that you like. Apart from donation, planting trees, volunteering or reducing your carbon footprint will be great too.
Advertisement
Tutorials
+8.4k Golang : Another camera capture GUI application with GTK and OpenCV
+36.1k Golang : Convert date or time stamp from string to time.Time type
+41.3k Golang : How do I convert int to uint8?
+50.6k Golang : Disable security check for HTTPS(SSL) with bad or expired certificate
+8.1k Golang : Count leading or ending zeros(any item of interest) example
+11.7k Golang : Setup API server or gateway with Caddy and http.ListenAndServe() function example
+17.3k Golang : delete and modify XML file content
+20.5k Golang : Convert date string to variants of time.Time type examples
+10.4k Golang : ISO8601 Duration Parser example
+14.7k Golang : Search folders for file recursively with wildcard support
+6.4k Golang : Embedded or data bundling example
+7.5k Golang : Test if an input is an Armstrong number example