Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // navigate users with url parameter offset for this test.
- // example.com/?offset=0 example.com/?offet=25
- // using this method to page the users likes ensures you are not making more than one api call on one php thus minimizing timeouts in curl. 2 api calls is 2 curl requests.
- //$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');
- if(!isset($_GET['offset'])){
- $user_profile = $facebook->api('/'.$id.'?fields=id,name,likes.offset(0),'GET');
- }
- if($_GET['offset']==='25'){
- $user_profile = $facebook->api('/'.$id.'?fields=id,name,likes.offset(25),'GET');
- }elseif($_GET['offset']==='50'){
- $user_profile = $facebook->api('/'.$id.'?fields=id,name,likes.offset(50),'GET');
- }elseif($_GET['offset']==='75'){
- $user_profile = $facebook->api('/'.$id.'?fields=id,name,likes.offset(75),'GET');
- }elseif(isset(($_GET['offset']) && $_GET['offset']!='75' && $_GET['offset'!='50' && $_GET['offset']!='25'){
- $user_profile = $facebook->api('/'.$id.'?fields=id,name,likes.offset(0),'GET');
- }
- } catch (FacebookApiException $e) {
- //handle the exception
- return NULL;
- }
- return $user_profile;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement