我有点失落,因为cURL对我来说是新事物而且很好......
我向不同的网站发送了一些信息 - 让我们调用我的网站A和我发送信息的网站,其中POST方法是网站B.
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,"https://www.siteB.com/request?form=json");
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS,
"externalId=" . $externalID . "&name=" . $name . "&surname=" . $surname . "&email=" . $email . "&phone=%2B" . $phone . "&operator=" . $operator . "&street=anon&city=anon&postCode=00000");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, false);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
$server_output = curl_exec($ch);
curl_close($ch);
echo $server_output;
此curl请求将我发送到页面http://siteA.com/some-values/abcdefgh-123456 - 它与file_stream类似,但我想重定向到http://siteB.com/some-values/abcdefgh-123456。
如果我使用
header('Location: www.siteB.com' . urlencode($server-output));
它仍然相同但不起作用:(
有人可以帮我吗?