PHP HTTP Request

9 views
Skip to first unread message

jj

unread,
Mar 13, 2009, 8:52:31 AM3/13/09
to Amee Developer
I'm developing a website project using PHP, and the http request code
I have for getting authorization from the AMEE database is:

$header = POST /auth HTTP/1.0\nAccept: application/xml\nHost:
http://stage.co2.dgen.net\nContent-Type: application/x-www-form-
urlencoded\nContent-Length: 36\n\nusername=/**username**/&password=/
**password**/;
$s = socket_create(AF_INET, SOCK_STREAM, 0);
$z = socket_connect($s, "193.34.29.200", $port);
socket_write($s, $header, strlen($header));

I got this code from the php with sockets example in the developers
area of the AMEE website.

This code is creating the connection between my website and the AMEE
website, but the http request above is causing a 400 bad request
error.

How do I change this code to get the authorisation token from the AMEE
website?

Thanks,
J.J.

Thade O'Connor

unread,
Mar 13, 2009, 3:36:10 PM3/13/09
to amee-de...@googlegroups.com
Hi J.J.

I tried that request, and got the same result as you.  This one works:

POST /auth HTTP/1.0
Accept: application/xml
Host: stage.co2.dgen.net
Content-Type: application/x-www-form-urlencoded
Content-Length: 35

username=********&password=********

the only difference is that the Host header is stage.co2.dgen.net rather than http://stage.co2.dgen.net.

Regards,

Thade

2009/3/13 jj <jjsh...@gmail.com>

Thade O'Connor

unread,
Mar 13, 2009, 3:39:02 PM3/13/09
to amee-de...@googlegroups.com
Sorry, I'm not sure how that blank line got in there, it should be:

POST /auth HTTP/1.0
Accept: application/xml
Host: stage.co2.dgen.net
Content-Type: application/x-www-form-urlencoded
Content-Length: 35

username=********&password=********

2009/3/13 Thade O'Connor <thade....@gmail.com>
Reply all
Reply to author
Forward
0 new messages