<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Ludicrous &#187; BasicAuth</title>
	<atom:link href="/tag/basicauth/feed" rel="self" type="application/rss+xml" />
	<link>https://lud.icro.us</link>
	<description></description>
	<lastBuildDate>Thu, 25 Apr 2013 01:15:13 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.6-beta1-23983</generator>
		<item>
		<title>Basic Authentication with the WordPress HTTP API</title>
		<link>https://lud.icro.us/wordpress-http-api-basicauth</link>
		<comments>https://lud.icro.us/wordpress-http-api-basicauth#comments</comments>
		<pubDate>Tue, 10 Aug 2010 17:36:57 +0000</pubDate>
		<dc:creator>John Blackbourn</dc:creator>
				<category><![CDATA[Default]]></category>
		<category><![CDATA[BasicAuth]]></category>
		<category><![CDATA[HTTP]]></category>
		<category><![CDATA[WordPress]]></category>

		<guid isPermaLink="false">https://lud.icro.us/?p=239</guid>
		<description><![CDATA[Basic Authentication (or BasicAuth) is not natively handled with the WordPress HTTP API. This means when you&#8217;re using functions such as wp_remote_get() and wp_remote_post() there&#8217;s no immediately obvious way to send Basic Authentication headers with your request. It would be great to pass username and password parameters to these functions, but it&#8217;s not there. Fear [...]]]></description>
				<content:encoded><![CDATA[<span class="read_later"><script type="text/javascript"><!--
			instapaper_embed( "https://lud.icro.us/wordpress-http-api-basicauth", "Basic Authentication with the WordPress HTTP API", "" );
		//--></script></span><p>Basic Authentication (or BasicAuth) is not natively handled with the <a href="http://codex.wordpress.org/HTTP_API">WordPress HTTP API</a>. This means when you&#8217;re using functions such as <code>wp_remote_get()</code> and <code>wp_remote_post()</code> there&#8217;s no immediately obvious way to send Basic Authentication headers with your request. It would be great to pass username and password parameters to these functions, but it&#8217;s not there.</p>
<p>Fear not though, it&#8217;s really easy. Here&#8217;s how:<br />
<code><br />
$args = array(<br />
  'headers' => array(<br />
    'Authorization' => 'Basic ' . base64_encode( YOUR_USERNAME . ':' . YOUR_PASSWORD )<br />
 )<br />
);<br />
wp_remote_request( $url, $args );<br />
</code></p>
<p>That&#8217;s it. The correct authentication headers will then be sent with your request (after you&#8217;ve replaced YOUR_USERNAME and YOUR_PASSWORD with the obvious).</p>
<p>I&#8217;d like to give a quick shout out to my favourite HTTP monitor <a href="http://www.charlesproxy.com/">Charles Proxy</a>. I use Charles almost daily when dealing with server-side HTTP requests and AJAX requests and it makes life much easier. I love it.</p>
]]></content:encoded>
			<wfw:commentRss>https://lud.icro.us/wordpress-http-api-basicauth/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>
