中继 $_POST,在没有 cURL 的情况下向外部页面添加身份验证


Relaying $_POST, adding authentication to external page without cURL

我正在尝试将表单中继到外部站点以将其处理并分类到数据库中,但我需要将基本身份验证添加到HTTP标头中。我对 HTTP 标头了解不多,并尝试这样做,但我对如何添加 $_POST 有效负载以及我是否正确完成了授权感到困惑。任何帮助将不胜感激!

<?php
$user = "snip";
$pass = "snip";
$header = "POST /WebServices/Post/?various_get=variables HTTP/1.1'n".
          "Host:snipped.domain'n".
          "Content-Type: application/x-www-form-urlencoded'n".
          "Content-Transfer-Encoding: quoted-printable'n".
          "User-Agent: PHP-Code'n".
          "Authorization: Basic ".base64_encode($user.':'.$pass)."'n".
          "Connection: close'n";
//Print post?
header('location:complete.html');
?>

主要是,我必须将新标题发送到外部页面,然后将用户重定向到其他地方。

好吧,如果没有 CURL,我知道的唯一另一种方法是打开套接字并手动发布。

使用 PHP 套接字发布数组