Access Your Desktop Development Environment from Your Mobile Device

It’s possible to get an iPhone, iPad, or Android device to access a local web server running on your development machine. All you need is an HTTP proxy such asĀ Charles Proxy running on your development machine. Once that’s running: Make sure your device is connected to the same network as your development machine. Go into the Settings -> Wi-Fi menu and find the HTTP proxy settings. On Android, this means a long-press on your Wi-Fi network (Modify Settings, then Show advanced settings). On iOS this means pressing the (i) icon next to your Wi-Fi network. Switch your proxy over to … Read more

Basic Authentication with the WordPress HTTP API

Basic Authentication (or BasicAuth) is not natively handled with the WordPress HTTP API. This means when you’re using functions such as wp_remote_get() and wp_remote_post() there’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’s not there. Fear not though, it’s really easy. Here’s how: $args = array( ‘headers’ => array( ‘Authorization’ => ‘Basic ‘ . base64_encode( YOUR_USERNAME . ‘:’ . YOUR_PASSWORD ) ) ); wp_remote_request( $url, $args ); That’s it. The correct authentication headers will then be sent with your request (after … Read more