WP_Http response throws "Cannot use object of type WP_Error as array"
My plugin is throwing the error "Cannot use object of type WP_Error as array". The line in question is...
$http = new WP_Http();
$response = $http-request( $url, array('timeout' = 20));
if( $response['response']['code'] != 200 ) { // THIS IS THE LINE
return false;
}
$upload = wp_upload_bits( basename($url), null, $response['body'] );
So the problem is $response only has one result, so it's not an array? How do I fix this?