[wp-hackers] POST with XML headers

Dion Hulse (dd32) wordpress at dd32.id.au
Fri Sep 16 15:13:29 UTC 2011


You'll need to look into using the wp_remote_*() set of functions,
which are part of the new HTTP API in WordPress.

References:
 http://codex.wordpress.org/HTTP_API
 http://kovshenin.com/archives/a-note-on-wp_http-and-http-requests-in-wordpress/

adapted from kovshenin's link, the curl command you've got would be
similar to this:

$url = 'https://company.freeagentcentral.com/company/users';
$username = 'your-username';
$password = 'your-password';
$headers = array(
     'Authorization' => 'Basic ' . base64_encode( "$username:$password" ),
     'Accept' => 'application/xml',
     'Content-Type' => 'application/xml'
);
$result = wp_remote_get( $url, array( 'headers' => $headers ) );

print_r($result);

Cheers
Dion / @dd32

On 17 September 2011 00:54, Tom Barrett <tcbarrett at gmail.com> wrote:
> Hi
>
> I'm looking at hooking into the free agent central API (
> http://www.freeagentcentral.com/developers/freeagent-api)
>
> This is there command line curl syntax:
> curl -u userid:password -H 'Accept: application/xml' -H 'Content-Type:
> application/xml' \
>  https://company.freeagentcentral.com/company/users
>
> My experience with curl related fetching of remote urls in WordPress is
> limited to wp_remote_fopen() which just takes the url as an argument. I've
> had a read through wp-includes/functions.php without seeing anything that
> would let me POST with xml headers. But I'm prone to missing things.
>
> Is there a something in WordPress for me to hook into to do this? Or is this
> just a job for curl from basics without any WordPress goodness wrapped
> around it?
>
> Thanks,
> Tom
> --
> http://gplus.to/tcbarrett
> _______________________________________________
> wp-hackers mailing list
> wp-hackers at lists.automattic.com
> http://lists.automattic.com/mailman/listinfo/wp-hackers
>


More information about the wp-hackers mailing list