robmcvey
robmcvey

Reputation: 815

Problem with HTTP POST request to HTTPS URL

I am using CakePHP "HttpSocket" class to post information to a Paypal payments server. My code is working fine when the target URL is http://www.something.com, I can parse the response as I would like.

However, when I am trying to post data to PayPals payment API URL (on HTTPS) I get no response whatsoever.

I have tried the same code on other HTTPS URLs, again no response.

What is the reason for this problem?

Upvotes: 0

Views: 2752

Answers (2)

RabidFire
RabidFire

Reputation: 6330

I realize this is over 2 years old, but I recently came across this issue and here's how I solved it:

You need to specify the port 443 along with the URL like so:

$httpSocket = new HttpSocket();
$httpSocket->get('https://domain:443/sample/path', array('q' => 'example'));

You can also pass the port and the host together in the third param, or use the request() method instead.

Hope this helps someone!

Upvotes: 1

jacobcat
jacobcat

Reputation: 11

i had the same problem as you... i seem not able to get any response from the Paypal API.

But I found out I just did something wrong. I was actually just doing a POST to https://www.sandbox.paypal.com, when in fact it should be https://www.sandbox.paypal.com/cgi-bin/webscr.

I realized this when I checked the $HttpSocket->response attribute of CakePHP, and I found out I've been getting 301 errors. Then I realized--it should not be on the base URL...

I then re-read the IPN Guide, and upon reviewing the sample codes there... voila! I realized my mistake.

Hope other people who uses CakePHP can benefit from this one. Took me long hours before I realized this one.

Upvotes: 1

Related Questions