diff --git a/src/wp-to-twitter-oauth.php b/src/wp-to-twitter-oauth.php index c4d9b2f..3520fa5 100644 --- a/src/wp-to-twitter-oauth.php +++ b/src/wp-to-twitter-oauth.php @@ -195,9 +195,15 @@ function wpt_update_oauth_settings( $auth = false, $post = false ) { if ( $connection ) { $data = $connection->get( 'https://api.twitter.com/1.1/account/verify_credentials.json' ); if ( '200' !== (string) $connection->http_code ) { - $data = json_decode( $data ); - $code = "" . $data->errors[0]->code . ''; - $error = $data->errors[0]->message; + $parsed = json_decode( $data ); + if ( is_object( $parsed ) ) { + $code = "" . $parsed->errors[0]->code . ''; + $error = $parsed->errors[0]->message; + } else { + $code = 'null'; + $error = __( 'Data was not returned in a recognizable format.', 'wp-to-twitter' ); + echo '
'; print_r( $data ); echo '
'; + } update_option( 'wpt_error', "$code: $error" ); } else { delete_option( 'wpt_error' );