How do I get URL from WP_HTTP object?

I’m using wp_remote_post: $test = wp_remote_post($environment_url, $args2 ); $test2 = $test[‘http_response’]; So what I want to do is get the value of URL but I believe the object is protected so having difficulty getting to it. The answer may be here WP_HTTP_Requests_Response But I need help finding it. Here is the output of $test2: WP_HTTP_Requests_Response … Read more

Storing an XML Response (Transient)?

Haven’t worked much with XML so I’m hitting a bit of a wall: function getapi() { $api_response = wp_remote_get( “http://example.com/getXML” ); $data = wp_remote_retrieve_body( $api_response ); $output = new SimpleXMLElement ($data ); return $output; } Get or set the Transient function transient() { $transient = get_transient( ‘transient_value’ ); if ( ! $transient ) { $transient … Read more

parse XML from URL (via SOAP)

I am attempting to build out a dashboard widget that will perform a validation check on a site RSS feed using the W3 Validator. Their API docs (http://feed2.w3.org/docs/soap.html) provide the method. Here is my function to get the data: $feed = ‘http://domain.com/feed/’; $request = new WP_Http; $url=”http://validator.w3.org/feed/check.cgi?url=”.urlencode($feed).’&output=soap12′; $response = wp_remote_get ( $url ); if( is_wp_error( … Read more

WP_Http_Cookie destroys cookie value through urldecode()

Background: Working on a Widget that uses a remote API using wp_remote_post to log into the service, once logged in storing the cookies received for the second request to query data with wp_remote_get. Problem: The cookies from the first request are stored in the response as WP_Http_Cookie objects and their values are run through urldecode … Read more

How to consume and display external data in WordPress from another website

I am trying to access data from another website to display on a WordPress Website I am developing. So far I have the following: <?php /* Template Name: Testing remote data */ get_header(); <div class=”main”> <div class=”col-sm-12″> <header> <h2>Testing remote data</h2> </header> </div> <div class=”container”> <div id=”content” role=”main”> <div class=”col-sm-12″> <?php $url=”http://www.bbc.co.uk/news/”;// this url is … Read more

Difference between wp_remote_post and wp_safe_remote_post

[*] [**]The documentation for wp_remote_post says [**]In many cases you may be better served with wp_safe_remote_post [**]Looking at the source code, the only line that’s different between the two is that wp_safe_remote_post has this: $args[‘reject_unsafe_urls’] = true; [**]This article was the best explanation I found, which seems to indicate that the only time I should … Read more