开发者

Problem with HTTP POST request to HTTPS URL

开发者 https://www.devze.com 2022-12-21 22:13 出处:网络
I am using CakePHP \"HttpSocke开发者_开发知识库t\" 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 respo

I am using CakePHP "HttpSocke开发者_开发知识库t" 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?


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.


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!

0

精彩评论

暂无评论...
验证码 换一张
取 消