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

---

# SOLVED: Cannot use object of type stdClass as array

 *  [Philosopher Rex](https://wordpress.org/support/users/ostralopithicus/)
 * (@ostralopithicus)
 * [10 years, 6 months ago](https://wordpress.org/support/topic/solved-cannot-use-object-of-type-stdclass-as-array/)
 * Whenever my cache was expired I was getting the error message “Fatal error: Cannot
   use object of type stdClass as array”.
 * I traced the error to the function oauthGetTweets (this function is located in
   the file “StormTwitter.class.php”).
 * The function was returning the result from twitter directly. I’m unclear why 
   this is causing the problem, but it is. I fixed it by changing the end line of
   this function to the following:
 *  $cacheRaw = file_get_contents($file);
    $cache = @json_decode($cacheRaw, true);
   return $cache[$cachename][‘tweets’]; //return $result;
 * So after the data is pulled form twitter and then json encoded into the cache,
   I’m just pulling it right back out using “json_decode($cacheRaw, true)”, which
   insures that it is a proper array.
 * I’m guessing that the result from twitter isn’t in a proper array form, but I
   really don’t know. I do know that it works now – no error.
 * [https://wordpress.org/plugins/oauth-twitter-feed-for-developers/](https://wordpress.org/plugins/oauth-twitter-feed-for-developers/)

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

 * ![](https://s.w.org/plugins/geopattern-icon/oauth-twitter-feed-for-developers.
   svg)
 * [oAuth Twitter Feed for Developers](https://wordpress.org/plugins/oauth-twitter-feed-for-developers/)
 * [Support Threads](https://wordpress.org/support/plugin/oauth-twitter-feed-for-developers/)
 * [Active Topics](https://wordpress.org/support/plugin/oauth-twitter-feed-for-developers/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/oauth-twitter-feed-for-developers/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/oauth-twitter-feed-for-developers/reviews/)

 * 0 replies
 * 1 participant
 * Last reply from: [Philosopher Rex](https://wordpress.org/support/users/ostralopithicus/)
 * Last activity: [10 years, 6 months ago](https://wordpress.org/support/topic/solved-cannot-use-object-of-type-stdclass-as-array/)
 * Status: not resolved