diff --git a/instagram-api/instagram-api.php b/instagram-api/instagram-api.php index 7d8cd9e..67fa26e 100644 --- a/instagram-api/instagram-api.php +++ b/instagram-api/instagram-api.php @@ -3,7 +3,7 @@ Plugin Name: Instagram Wordpress API Plugin URI: http://github.com/msigley/ Description: Provides functions for accessing the Instagram API. Leverages the Wordpress HTTP API. -Version: 2.0.1 +Version: 2.0.2 Author: Matthew Sigley License: GPL2 */ diff --git a/instagram-api/rest.php b/instagram-api/rest.php index 7c3c5f3..9ce38d1 100644 --- a/instagram-api/rest.php +++ b/instagram-api/rest.php @@ -66,9 +66,13 @@ public function request( $endpoint, $method, $body = array(), $cache = true, &$r if( 200 != $response_code && 400 != $response_code ) return false; - $response_body = wp_remote_retrieve_body( $response ); - $this->cache_request( $response_body, $endpoint, $method, $body ); - return json_decode( $response_body ); + $response_body = wp_remote_retrieve_body($response); + $response_body_json = json_decode($response_body); + if (isset($response_body_json->error) || !isset($response_body_json->data)) { + return false; + } + $this->cache_request($response_body, $endpoint, $method, $body); + return $response_body_json; } private function get_cached_request( $endpoint, $method, $body=array() ) {