facebook twitter hatena line email

Php/curl/basic認証

提供: 初心者エンジニアの簡易メモ
移動: 案内検索
$post['hoge'] = 'piyo';
$chost = curl_init();
curl_setopt($chost, CURLOPT_URL, 'ttp://example.com/');
curl_setopt($chost, CURLOPT_POST, true);
curl_setopt($chost, CURLOPT_POSTFIELDS, $post);
curl_setopt($chost, CURLOPT_RETURNTRANSFER, true);
curl_setopt($chost, CURLOPT_USERPWD, $USERNAME . ':' . $PASSWORD);
$result = curl_exec($chost);
curl_close($chost);
echo $result;