xml POST method using http protocol

i got a link from a travel hotel booking people like bellow link

Each request needs to be posted (through POST method) using http protocol to http://xmldev.dotwconnect.com/request.dotw and it receives a response irrespectively the request is successfully processed or not informing about the success of the operation.

how i can create a xml post method using php

PHP5+, you can also use the stream functions.
http://www.php.net/manual/en/book.stream.php
http://www.php.net/manual/en/function.stream-socket-client.php

or the similar fsockopen() in PHP4:
http://www.php.net/fsockopen

With both of these you will create the raw HTTP request to send over TCP. However, if you need something more abstracted like cURL, you can use fopen(), with stream_context_create() in PHP5:
http://www.php.net/manual/en/function.fopen.php
http://www.php.net/manual/en/function.stream-context-create.php

There are also many HTTP libraries based on fsockopen and stream_socket_client. You can use these or follow their examples.
http://pear.php.net/package/HTTP

PHP5+, you can also use the stream functions.
http://www.php.net/manual/en/book.stream.php
http://www.php.net/manual/en/function.stream-socket-client.php

or the similar fsockopen() in PHP4:
http://www.php.net/fsockopen

With both of these you will create the raw HTTP request to send over TCP. However, if you need something more abstracted like cURL, you can use fopen(), with stream_context_create() in PHP5:
http://www.php.net/manual/en/function.fopen.php
http://www.php.net/manual/en/function.stream-context-create.php

There are also many HTTP libraries based on fsockopen and stream_socket_client. You can use these or follow their examples.
http://pear.php.net/package/HTTP

Those are all pretty much WAY overkill for what he needs. He's just trying to hit an API but the API writers evidently like their job too much and wrote the description in an extremely overtechnical way.

Those are all pretty much WAY overkill for what he needs. He's just trying to hit an API but the API writers evidently like their job too much and wrote the description in an extremely overtechnical way.

I find the stream_context_create() function simpler then cURL since you don't have to remember or look up all those CURLOPT_* constants.

// the xml to send
$xml = 'your xml payload';

// build your http request
$context = stream_context_create(array( 
    'http' => array( 
      'method'  => 'POST', 
      'header'  => "Content-type: text/xml\r\n", 
      'content' => $xml, 
      'timeout' => 10, 
    ), 
  )); 

// send it
  $resp = file_get_contents('http://xmldev.dotwconnect.com/request.dotw', false, $context);

hi
can anybody tell me how to use php with xml post.plz give some example.i go through php site but not able to find it.

plz help me asap.

thanks

hi
can anybody tell me how to use php with xml post.plz give some example.i go through php site but not able to find it.

plz help me asap.

thanks

The last post in the thread is an example of a HTTP POST of XML content. Are you having problems with it?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.