facebook connect api "Cannot use string offset as an array in" error -


Please help! I have been suffering from this error for several days and I can not understand it for my life. I am using a "contact_email" attribute using the Facebook Connect and "API method users_getInfo".

The problem is that when I execute this PHP file, I get this error: "String offset can not be used as an array ...". This error typically refers to this line of code: $ firstName = $ user_details [0] ['contact_email'];

I'm thinking because the user_getInfo method is not returning any results ... However, the most ridiculous part about this is that I can execute the code several times in the row successfully above Without error, but without changing any code, I will suddenly face this error, in which case I will get dozens of errors at times, and then any code change Without the rest, start executing successfully again.

This strange behavior happens when I forget that attribute .. (contact_email, first_name, last_name, etc.). I'm running PHP 5.2.11 Am I missing something ??

Please help!

include_once 'site / fbconnect / config.php'; // $ api_key and $ is defined in the secret Include_once 'site / facebook-platform / client / facebook.php'; Global $ api_key, $ secret; $ Fb = new Facebook ($ api_key, $ secret); $ FB-> require_login (); $ Fb_user = $ fb-> get_loggedin_user (); $ User_details = $ fb-> api_client-> users_getinfo ($ fb_user, array ('last_name', 'first_name', 'contact_email'));
$ email = $ user_details [0] ['contact_email']; $ FirstName = $ user_details [0] ['first_name']; $ LastName = $ user_details [0] ['last_name'];

Using Facebook Flick Client API I was also getting the error, but my mistake was Whether the friends are friends using Friends phaco php method or friends.

// $ results_array = $ facebook-> api_client-> friends_apaign ($ fb_user, $ selected_friend_uid); // $ answer = $ results_array [0] ['are_friends'];

I get this error when I specified a $ result, "string offset can not be used as an array", much was unsuccessful. My solution was to create that loop for that code And then to check the $ answer to see if it is using an array PHP method is_array () and then re-implements the method if it was not. At the end, my loop was just for 10 attempts before failing it, this check was severely disappointing the performance of my Facebook app. Instead, I removed the API call for friends' friends and made my Facebook app's performance again and again.

You can probably apply a similar feature which can allow the method to retry itself if the result is not an array. I think the problem is on Facebook, sometimes they flood and requests are not completed successfully. I warn you do not try more than 5 attempts, although if you loop forever , The rest assured that they will prevent you from using Facebook API for flooding, so be careful.


Comments

Popular posts from this blog

sql - dynamically varied number of conditions in the 'where' statement using LINQ -

asp.net mvc - Dynamically Generated Ajax.BeginForm -

Debug on symbian -