Title: Cannot use object of type stdClass as array
Last modified: August 22, 2016

---

# Cannot use object of type stdClass as array

 *  Resolved [P T](https://wordpress.org/support/users/pthomson87/)
 * (@pthomson87)
 * [11 years, 8 months ago](https://wordpress.org/support/topic/cannot-use-object-of-type-stdclass-as-array-2/)
 * Hello,
 * My previous post was closed as it was not for the current version of the plugin
   but problem still persists.
 * Solution: Use the second parameter of json_decode on effected lines to make it
   return an array:
 * `$result = json_decode($data, true);`
 * source: [http://stackoverflow.com/questions/6815520/cannot-use-object-of-type-stdclass-as-array](http://stackoverflow.com/questions/6815520/cannot-use-object-of-type-stdclass-as-array)
 * > 2014/01/29 22:39:24 [error] 2947#0: *140010 FastCGI sent in stderr: “PHP message:
   > PHP Fatal error: Cannot use object of type stdClass as array in /xxxxxxxxxx/
   > www/wp-content/plugins/floating-social-bar/class-floating-social-bar.php on
   > line 687” while reading response header from upstream, client: xx.xx.xxx.xxx,
   > server: festivalarchive.com, request: “POST /wp-admin/admin-ajax.php HTTP/1.1”,
   > upstream: “fastcgi://unix:/dev/shm/php-fpm-www.sock:”, host: “www.xxxxxxx.com”,
   > referrer: “[http://www.xxxxxx.com/xxxxxx/&#8221](http://www.xxxxxx.com/xxxxxx/&#8221);
 * It would be good if this simple fix would be added in future releases.
 * thanks,
    Paul
 * [https://wordpress.org/plugins/floating-social-bar/](https://wordpress.org/plugins/floating-social-bar/)

Viewing 2 replies - 1 through 2 (of 2 total)

 *  [jgng](https://wordpress.org/support/users/jgng/)
 * (@jgng)
 * [11 years, 7 months ago](https://wordpress.org/support/topic/cannot-use-object-of-type-stdclass-as-array-2/#post-5289481)
 * Hello, I am also experiencing this problem.
 *  Thread Starter [P T](https://wordpress.org/support/users/pthomson87/)
 * (@pthomson87)
 * [11 years, 7 months ago](https://wordpress.org/support/topic/cannot-use-object-of-type-stdclass-as-array-2/#post-5289487)
 * Found the solution… for me it was caused because there were too many calls from
   my server to the facebook api.
 * Fix: Change the default way to get social info to using your own api keys (you’ll
   have to create an app for this if you haven’t done so already).
 * Change class-floating-social-bar.php lines 681 – 700ish to
 *     ```
       foreach ( (array) $services as $service ) {
       // Update an individual service.
       switch ( $service ) {
       case 'facebook' :
   
       $facebook_url = 'https://graph.facebook.com/?id=' . $post_url . '&access_token=XXAPI-IDXX|xxSECRET-KEY-ID-THINGxx';
       $facebook_stat = json_decode( wp_remote_fopen( $facebook_url ), true );
   
       $stats['facebook'] = empty( $facebook_stat['shares'] ) ? '0' : (int) $facebook_stat['shares'];
       update_post_meta( $post_id, 'fsb_social_facebook', $stats['facebook'] );
   
       break;
       ```
   
 * Let me know if this works for you,
 * Best of luck,
    Paul

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘Cannot use object of type stdClass as array’ is closed to new replies.

 * ![](https://s.w.org/plugins/geopattern-icon/floating-social-bar_f3f3f3.svg)
 * [Floating Social Bar](https://wordpress.org/plugins/floating-social-bar/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/floating-social-bar/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/floating-social-bar/)
 * [Active Topics](https://wordpress.org/support/plugin/floating-social-bar/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/floating-social-bar/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/floating-social-bar/reviews/)

 * 2 replies
 * 2 participants
 * Last reply from: [P T](https://wordpress.org/support/users/pthomson87/)
 * Last activity: [11 years, 7 months ago](https://wordpress.org/support/topic/cannot-use-object-of-type-stdclass-as-array-2/#post-5289487)
 * Status: resolved