简体   繁体   中英

php curl post redirect

Im trying to integrate a bank api for redirect payment. Im using curl post method but i want to be able to follow the redirect after the post. Here is my code

curl_setopt($ch, CURLOPT_URL, 'https://paycenter.piraeusbank.gr/redirection/pay.aspx');  
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); 
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, array(
    'data' => $data
));
$content = curl_exec($ch);

After the post it supposed that i have to be redirected in a url like

https://paycenter.piraeusbank.gr/redirection/4234sgsfdgfsg/pay.aspx

Instead of that im redirecting to:

http://mytestdomain.org/redirection/4234sgsfdgfsg/pay.aspx

which obviously ends up in 404 error

您需要操纵响应,然后编写硬代码,以便在curl在服务器上执行该URL时将该脚本重定向到特定页面。

Try to add the following code:

curl_setopt($ch, CURLOPT_AUTOREFERER, TRUE);

This will automatically set the Referer, example: redirection.

EDIT :Check out this answer Here , Maybe it will help you out a little.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM