Problem with HTTP POST request to HTTPS URL - http

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?

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!

Related

HTTP to HTTPS issues

I have a question, I am a bit confused, I don't really understand why this is happening.
I have a website which works well over http. When I force redirect to https something happens. Even if I replace all my urls in my code, only GET request will work. Anybody has any idea why is this happening?
I also have admin part of the website. it works to login into the admin but it doesn't work to make any requests on it. I am trying to post or delete but I receive a 401 err, even if I am logged in and set the token right...
So bottom line is:
On Https, the website works, it shows all the resources from the db, I can login in the Admin but I can not post or delete.
On Http everything works.
I am in a huge need of advice or ideas.
thanks.
From my experience you cannot serve mixed content, that's my first suggestion is to call all your scripts/dependencies without the prefix; ie: script src="https://blahblah" to "script src="//blahblah"; you're going to make sure you are sticking consistently to one serving source; so that's the first thing I'd check (also look at console logs, they often give hints as to what failed);
Secondly I am unsure of the response or how the server handles traffic from non https, possibly there's a rule in htaccess or some form of redirection trying to force the call via https so http fails? these are all steps in debugging right you need to troubleshoot and play process of eliminations; first though I'd make sure we are serving everything from // or https; when on http I would look at console logs for clues but even more so I would force a redirect to use https exclusively (as most sites do now)
Check for mixed content issues first though, this is something that can have a multitude of solutions based on the many variations of what could be causing this issue.

Could someone give me a url that uses POST method?

I am writing a http proxy and I need to test if it can handle POST requests, but I can not find a URL that uses POST method.
Could someone give me one?
Thanks.
Try this one: http://ptsv2.com/
Read the instructions on the page. To help you further, I suggest that you use Postman, (it doesn't answer requests but is a great tool to help you compose your requests)
Also you need to show that you've done some research first. Or your question will get downvoted to hell.

What HTTP Status Code should be used for redirecting to a correct URL?

I am not so sure if the the title of the question is perfect to ask but here is what I am trying figure out. Of course in relation to SEO and such things.
You might have seen URLs with numbers at the end in addition to the title/slug in the URL. Such as
/topic/new-topic-at-this-website-1234
The web application actually takes that number (at the end) as an identity to the resource to deliver. So changing that number in the URL brings up another resource but in that case not all but some websites changes the full URL and redirect to the correct resource with correct URL. Even though some websites do not change the URL and just deliver the content.
While I want to redirect the user to correct URL if the numeric values changes, what status code should be used in that case?
Hope I have asked the question correctly.
OK, Until I find a suggestion, I am going use status code 301 for such redirection because I just found that in fact stackoverflow is handling the same case with 301. As requesting this page with following link,
/questions/33775526
redirects to
/questions/33775526/what-http-status-code-should-be-used-for-redirecting-to-a-correct-url
with status code 301.
Advices are still welcomed but

How to make spray-can client follow redirects

When requesting some pages with the following code:
HttpDialog(httpClient, IDN.toASCII(domain)).send(HttpRequest(uri = "/")).end
spray-can client returns responses with redirects to another URLs (e.g. 302 Found). Is there a standard way of telling spray to automatically follow redirects? And if not, what is the best way to implement this behavior myself with akka futures?
Update 2: The PR was merged and documentation for redirection following is spray-can can now be found here
Update: I decided to have a crack at implementing this and have sent a PR. Hopefully it will get merged.
There is no way to currently tell spray-can client to follow 3xx redirects. See this thread for more details.
There is an open ticket, so hopefully this will happen in the future. I'm sure a contribution would be welcomed.

Link to add ics to Google Calendar stopped working

I have a link on a website to let users add an ICS feed to their google Calendar. Using this code:
http://www.google.com/calendar/render?cid=https://<etc>
It worked for 3-4 years but not anymore. The message Google sends me is:
This email address isn't associated with an active Google Calendar account: https://<etc>
If I enter the ics feed manually things work ok: the feed is parsed as should. No errors.
Any idea where to look to fix this?
I too have this problem. Did you solve it?
My tests show that it works when using URLs with http, like:
www.google.com/calendar/render?cid=http%3A%2%2Fwww.example.com%2FCalendar%2FPublic%2520Events.ics
But not with https, like:
www.google.com/calendar/render?cid=https%3A%2%2Fwww.example.com%2FCalendar%2FPublic%2520Events.ics
My workaround for this is to use http in the link, but redirect it to https in the web server. Not very elegant, but it works. The GET won't be encrypted, but at least the answer is.
EDIT: Actually, it can be a huge security risk sending the GET over http instead of https if you don't do any more authentication than via query string parameters, which can be hard for calendar feeds. Anyone who can sniff the GET can send the same request over https themselves.
Right now it works, even with https.
https://www.google.com/calendar/render?cid=https%3A%2F%2Fwww.example.com%2FCalendar%2FPublic%20Events.ics
Use webcal protocol for the calendar address:
https://www.google.com/calendar/render?cid=webcal%3A%2F%2Fwww.example.com%2FCalendar%2FPublic%20Events.ics
Ok, so for me, none of the other answers on this page worked. But I figured it out with bits and pieces of others:
Link to my calendar's ics:
https://example.com/calendar?id=a304036ea5a474ee5d80a100d79c231c
The right way to link it to Google Calendar:
https://calendar.google.com/calendar/r?cid=webcal%3A%2F%2Fexample.com%2Fcalendar%3Fid%3Da304036ea5a474ee5d80a100d79c231c
The key here is adding it using the webcal protocol instead of the https protocol.
Hope this helps anyone.
They got more strict.
Now you have to use
http://www.google.com/calendar/render?cid=http%3A%2F%2Fwww.example.com%2FCalendar%2FPublic%2520Events.ics
note the encoding.

Resources