Hey guys
I have this piece of code which works 90% of the time:
$user_details=$fb->api_client->users_getInfo($fb_user, array('last_name','first_name','proxied_email')); $firstName=$user_details[0]['first_name'];
But sometimes I get this error:
Fatal error: Cannot use string offset as an array for line $firstName=$user_details[0]['first_name'];
I have read several people report the same issue - but I'm still not clear as to what is the reason - Am I getting this error because facebook is not returning any results or am I getting because it is returning only a single array instead of array of arrays.
This is the fix I'm thinking of:
if (!is_array($user_details)) { $firstName=''; } else { $firstName = ($user_details[0]) ? $user_details[0]['first_name'] : $user_details['first_name']; }
Also if I'm not getting the name - is it because of a timeout issue or something else?
Thanks