This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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); |
headers に ‘Authorization: Basic ‘ を渡せば良いです。
ユーザー名、パスワードは : (コロン) で区切って base64_encode() してやればおっけ。
コメントを残す