4

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

3
  • Do you have any redirect code??? or its redirect automatically? Commented May 19, 2015 at 8:48
  • If i make a simple post from an html form it redirects me to the banks page Commented May 19, 2015 at 8:50
  • So you don't have redirection code. Commented May 19, 2015 at 8:59

2 Answers 2

1

You need to manipulate your response and then write hard code to redirect this script to particular page as curl execute that url on your server.

Sign up to request clarification or add additional context in comments.

1 Comment

can you give an example? as i understand first i want to block the redirection and then grab the headers from curl with the redirect url and after redirect the user
0

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.

1 Comment

I get the same result with CURLOPT_AUTOREFERER, TRUE,ive tried to also add CURLOPT_REFERER, paycenter.piraeusbank.gr but with the same result

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.