Skip to content

Instantly share code, notes, and snippets.

@wokamoto
Last active December 16, 2015 14:29
Show Gist options
  • Save wokamoto/5448820 to your computer and use it in GitHub Desktop.
Save wokamoto/5448820 to your computer and use it in GitHub Desktop.
[WordPress] wp_remote_get で BASIC 認証がかかったページからデータを取得する。
<?php
$user = 'username';
$password = 'password';
$url = 'http://example.com/';
$args = array(
'headers' => array(
'Authorization' => 'Basic '.base64_encode("$user:$password")
)
);
$result = wp_remote_get($url, $args);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment