3

I currently have the following snippet of php to fetch some HTML and render it in my theme(squash theme).

<?php $response = wp_remote_get( 'http://www.toucan-it.co.uk/wp-content/themes/squash/index5.html' );

print $response ['body']; ?>

The file I'm trying to request is available at the following URL.

http://www.toucan-it.co.uk/wp-content/themes/squash/index5.html

Problem

The problem is when trying to retrieve ‘index5.html’ via the web browser the output of the file is generated but when calling it via ‘wp_remote_get’ using either absolute or relative paths an error is displayed.

When doing a var_dump of $response

The output can be seen on the homepage, beneath the sliders on the home page. You can see what should be rendered by the php file under the error code by looking at the Circles below (http://www.toucan-it.co.uk)

object(WP_Error)#337 (2) { ["errors"]=> array(1) { ["http_request_failed"]=> array(1) { [0]=> string(24) "couldn't connect to host" } } ["error_data"]=> array(0) { } } 
2
  • Try: $http = new WP_Http(); var_dump($http->_get_first_available_transport(array(),'example.com'));. What do you get?
    – s_ha_dum
    Sep 8, 2013 at 16:17
  • This isn't the problem as when locating the file from within a dropbox account and calling the file using the public URL it was displayed fine. Sep 9, 2013 at 9:35

1 Answer 1

1

Try to increase the timeout (default is 5).

$response = wp_remote_get( 'http://www.toucan-it.co.uk/wp-content/themes/squash/index5.html', array( 'timeout' => 120, 'httpversion' => '1.1' ) );
1
  • Updated the code and nothing happend, upon doing a 'var_dump' of '$response' the same error is still being produced Sep 7, 2013 at 13:31

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.