【发布时间】:2013-07-24 06:40:41
【问题描述】:
我需要使用 http_build_query 创建一个 POST 请求。以下是我的代码:
$uri_args = array (
'name' => 'Jack',
'surname' => 'Jackson',
'username' => 'jackson12',
'email' => 'Jack@mail.com',
);
$uri = http_build_query($uri_args);
header("Location: http://samplesite.com?$uri");
目前它会生成一个类似 GET 的请求,但我需要 POST。 考虑到我不想使用 curl,......只有 http_build_query。
【问题讨论】:
-
希望对您有所帮助,stackoverflow.com/questions/611906/…
-
你在那里做的不是
POST,是GET。要创建POST请求,请使用cURL,类似于http://www.php.net/manual/en/function.curl-exec.php#98628 -
现在我看到你不想使用 cURL。另一种选择是使用fsocketopen,类似于stackoverflow.com/questions/2367458/…
-
@machineaddict,我知道,我需要使用 http_build_query 而不是 cURL 请求 POST。
-
http_build_query 只生成一个字符串,与发送请求无关。