Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //$id is the user id
- //$fields is the information to get: first_name, last_name, friends, likes...
- //$facebook is the object obtained from: $facebook = new Facebook($config)
- function get_user_info($id, $fields, $facebook) {
- try {
- $user_profile = $facebook->api('/'.$id.'?fields='.$fields,'GET');
- } catch (FacebookApiException $e) {
- //handle the exception
- return NULL;
- }
- //handle with paged likes
- if (array_key_exists('next',$user_profile['likes']['paging'])) {
- $after = $user_profile['likes']['paging']['cursors']['after'];
- try {
- $new = $facebook->api('/'.$id.'/likes?after=' . $after, 'GET');
- $n = $new; //to get right 'after'
- while(array_key_exists('next',$n['paging'])) {
- $after = $n['paging']['cursors']['after'];
- $n = $facebook->api('/'.$id.'/likes?after=' . $after, 'GET');
- $new = array_merge_recursive($new,$n);
- }
- $user_profile = array_merge_recursive($user_profile,array("likes"=>$new));
- unset($user_profile['likes']['paging']);
- } catch (FacebookApiException $e) {
- //...
- }
- }
- return $user_profile;
- }
Advertisement
Add Comment
Please, Sign In to add comment