Articles of wp remote get

Wrapping add_query_arg with esc_url not working

I know about the XSS issue related to add_query_arg()function. That is why I am wrapping it with esc_url(). Problem is…this is not working with wp_remote_get(). If I go: $url = add_query_arg( array( ’email’ => ‘myadress@mail.com’, ‘token’ => ‘899A762614F6C49809A374FB955EC8C15’), ‘https://example.com/v3/transactions/notifications/3FF732-68B436B43622-3664083FB82B-CFB043’ ); $response = wp_remote_get( $url ); I am getting a valid body response. But if I […]

wp_remote instead of file_get_contents on non json

I have searched this website and although there are a lot of threads regarding the wp_remote functions but none are what I am asking and would like to know if its possible. I am wanting to scrape a website and get a specific div#id and grab its elements within that section. I can do this […]

How to add Request header in WordPress remote api calls

Hey am new to WP development, can any one tell me how to add request headers in wp_remote_get() or wp_remote_post() remote api calls. I tried the following but didnt work $response = wp_remote_get( add_query_arg( array( ‘Affiliate-Id’ => XXXXX, ‘Affiliate-Token’ => XXXXX ), $api_url ) , array( ‘timeout’ => 10));

http_response_timeout filter not working

I am writing a WordPress plugin that makes calls to external sites. I want to raise the timeout for all wp_remote_* calls, so I added the following to the __construct function of my plugin: add_filter(“http_response_timeout”, function($timeout) { return 30; }); But the calls still time out after 5 seconds. I also tried using a separate […]

Errors on a single host using wp_remote_get() unless sslverify is set to false

I’m testing a plugin on HostGator, GoDaddy, DreamHost and DigitalOcean, developing locally with VVV. I’m running WordPress 4.4.2 across the board. I’m using wp_remote_get() to retrieve weather data from NOAA’s Text Data Server using 3 different endpoints. I ran into trouble when I extended testing to another host, Arvixe, where I was getting a 400 […]

WP_Remote_Get Not working

I have a plugin which uses wp_remote_get() and it’s not working on my nginx server so I decided to test this. I created a file called test.php and inserted: <?php $response = wp_remote_get( ‘http://www.domain.com/mytest.php’ ); print $response [‘body’]; ?> When I run this file I am getting error: 2017/02/04 16:22:31 [error] 16573#16573: *461100 FastCGI sent […]

Fetching data from another website results in a slow website?

I am fetching data from another website with the following code: <?php // IOCS logos $logos_url = ‘https://www.someurl’; $logos_request = wp_remote_get( $logos_url ); if(is_wp_error($logos_request)) { return false; } $logos_body = wp_remote_retrieve_body( $logos_request ); $logos_data = json_decode( $logos_body ); // OSCS logos $oscs_logos_url = ‘https://www.someurl’; $oscs_logos_request = wp_remote_get( $oscs_logos_url ); if(is_wp_error($oscs_logos_request)) { return false; } $oscs_logos_body […]

using wp_remote_get to retrieve own url on local host

I have a website in local development at test:8888 and I am trying to get the following to work in my functions.php file. $response = wp_remote_get( ‘test:8888/?p=1’ ); print_r($response); Unfortunately this is printing WP_Error Object ( [errors] => Array ( [http_request_failed] => Array ( [0] => A valid URL was not provided. ) ) [error_data] […]

wp_remote_get sslv3 alert handshake failure

I’m attempting to retrieve remote content with wp_remote_get but I’m getting the following error returned : ‘sslv3 alert handshake failure’. I’ve tried using ‘sslverify’ => false in the args array, but to no avail. This was working fine on the dev server, but no more, so I’m assuming it’s a server/apache configuration issue. Any ideas […]

Strange Situation When Try To Retrieve Github Gist Using wp_remote_get

I have fall in a strange situation. Take a look at below code: <?php $args = array( ‘headers’ => array( ‘Accept’ => ‘application/vnd.github.v3+json’, ‘Authorization’ => ‘token 05b2d30a01f60cf09b7af08be8f322b4fd7d831f’ ) ); $response = wp_remote_get( ‘https://gist.github.com/kampas/63abfe8435d461d30099’, $args ); print_r($response); ?> This code show: [response] => Array ( [code] => 406 [message] => Not Acceptable But when I remove […]