php cURL POST如何遵循位置 [英] php cURL POST how to follow location

查看:83
本文介绍了php cURL POST如何遵循位置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我对cURL问题感到不满意。该帖子的效果很好,数据可以很好地发布并且可以正常接收,但是执行cURL会话后,发布的页面的URL永远不会出现在浏览器中,例如,查看以下代码:

I am in a bit of a rut with a cURL issue. The post works greate, the data is POSTED just fine and received ok, but the url of the posted page never appears in the browser after the cURL session is executed, for example look at the following code:

    $ch = curl_init("http://localhost/eterniti/cart-step-1.php");
    curl_setopt($ch, CURLOPT_HEADER, false);
    curl_setopt($ch, CURLOPT_POST, true);
    curl_setopt($ch, CURLOPT_POSTFIELDS, "error=1&em=$em&fname=$fname&lname=$lname&email1=$email1&email2=$email2&code=$code&area=$area&number=$num&mobile=$mobile&address1=$address1&address2=$address2&address3=$address3&suburb=$suburb&postcode=$postcode&country=$country");
    curl_exec($ch);
    curl_close($ch);

帖子工作正常,我被带到cart-step-1.php文件,我可以在其中进行处理发布的数据,但是浏览器的URL地址栏中的位置仍然是脚本页面的位置,在这种情况下为proc_xxxxxx.php

The post works fine and I am taken to the cart-step-1.php where I can process the posted data, HOWEVER the location in the URL address bar of the browser remains that of the script page, in this case proc_xxxxxx.php

任何获取URL的想法地址以反映我实际上已张贴到的页面?

Any ideas how to get the URL address to reflect the page I am actually POSTED to?

感谢工厂

推荐答案

您可以使用 curl_getinfo 来获取最后一个URL您已重定向到:

You can use curl_getinfo to get the last URL you were redirected to:

$url = curl_getinfo($ch , CURLINFO_EFFECTIVE_URL);

,然后使用标题

这篇关于php cURL POST如何遵循位置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆