Searching for a very simple HTTP POST function

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
mihalka
Forum Newbie
Posts: 10
Joined: Thu Oct 13, 2005 2:19 pm

Searching for a very simple HTTP POST function

Post by mihalka »

I need a HTTP function for a very simple task for the following communication. I already compared different functions / libraries - but they are too complicated for the simple job here:

Please help me. Thanks in advance.

THE REQUEST:

POST /servlet/portal/xml-api HTTP/1.1
User-Agent: Java/1.5.0_02
Host: localhost:8080
Accept: text/html, image/gif, image/jpeg, *; q=.2, */*; q=.2
Connection: keep-alive
Content-type: application/x-www-form-urlencoded
Content-Length: 208

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE PORTAL SYSTEM "http://localhost:8080/servlet/media/xml/api/request.dtd">
<PORTAL TransId="">
<AUTH>
<SESSION Key="OWOwZQpB6AyTxCj0" />
</AUTH>
</PORTAL>

THE RESPONSE:

HTTP/1.0 200 OK
Content-Type: text/xml
Date: Tue, 01 Nov 2005 20:32:24 GMT
Server: Tomcat Web Server/3.3a Final ( JSP 1.1; Servlet 2.2 )

<?xml version="1.0" encoding="UTF-8"?>

<!DOCTYPE RESPONSE SYSTEM "http://michel:8080/servlet/media/xml/api/response.dtd">
<RESPONSE TransId="" Auth="true">
</RESPONSE>
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

cURL is the only set of functions in PHP that can perform a POST without too much pain.. but it may not be built into the server(s) you run on.. fsockopen() will more likely exist, but takes more work to set up and could also be disabled.
mihalka
Forum Newbie
Posts: 10
Joined: Thu Oct 13, 2005 2:19 pm

Post by mihalka »

Hi Feyd, thanks a lot for your quick answer. I need some explanation to your message:

1. but it may not be built into the server(s) you run on - you mean that either curl is not available for the php engine * operating system comination, or I don't have the appropriate compiler fot the OS ?
2. fsockopen is a part of the php core, Isn't it ? That means it is always available.. or not ?
3. "could also be disabled" - disabled ? Where on the OS level ? I saw some HTTP functions, they use that function (perhaps curl) too. Therefore HTTP will be disabled too..

Please correct me, if I'm wrong.

Thanks in advance,

Laszlo
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

  1. cURL is a compile option during installation on *nix systems, and a linked extension on Windows servers. I've seen many hosts not have it installed.
  2. fsockopen is a core function, but can be disabled very easily in php.ini, and probably during compilation as well
Post Reply