Skip to content

Instantly share code, notes, and snippets.

@davidrecordon
Created May 10, 2010 09:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save davidrecordon/395844 to your computer and use it in GitHub Desktop.
Save davidrecordon/395844 to your computer and use it in GitHub Desktop.
<?php
// you need an access token, and it might require the user_likes permission.
// see http://developers.facebook.com/docs/authentication. Just trying this
// out for yourself, grab one of your access tokens from
// http://developers.facebook.com/docs/api.
$access_token = '';
$user = '';
$api = 'https://graph.facebook.com/';
$data = file_get_contents($api . $user . '/likes?access_token=' . $access_token);
$raw_likes = json_decode($data, true);
if (!array_key_exists('data', $raw_likes)) {
die;
}
$like_ids = array();
foreach($raw_likes['data'] as $raw_like) {
array_push($like_ids, $raw_like['id']);
}
// this data is public, no SSL or access token required
$like_data = file_get_contents('http://graph.facebook.com/?ids=' . implode(",", $like_ids));
$likes = json_decode($like_data, true);
foreach($likes as $key => $value) {
// we're only interested in things I liked via Social Plugins
if (strstr($value['link'], 'http://www.facebook.com/')) {
continue;
}
print_r($value);
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment