diff --git a/disqus/lib/api/disqus/disqus.php b/disqus/lib/api/disqus/disqus.php index bbf44f8..0f25217 100644 --- a/disqus/lib/api/disqus/disqus.php +++ b/disqus/lib/api/disqus/disqus.php @@ -115,11 +115,23 @@ function call($method, $args=array(), $post=false) { $args = null; } - if (!($response = dsq_urlopen($url, $args)) || !$response['code']) { - $this->last_error = 'Unable to connect to the Disqus API servers'; + if ( null === $args ) { + $response_raw = wp_remote_get( $url ); + } else { + $response_raw = wp_remote_post( $url, array( 'body' => $args ) ); + } + + if ( is_wp_error( $response_raw ) ) { + $this->last_error = $response_raw->get_error_message(); return false; } + $response = array( + 'code' => wp_remote_retrieve_response_code( $response_raw ), + 'data' => wp_remote_retrieve_body( $response_raw ), + 'headers' => wp_remote_retrieve_headers( $response_raw ), + ); + if ($response['code'] != 200) { if ($response['code'] == 500) { // Try to grab the exception ID for better reporting