tags:

views:

39

answers:

4

Hallo,

I need to send a request to a page (POST) and then, I will read the XML and take the logical action.

How can I best send from my PHP request and then read the response. Thnkas.

A: 

You need a HTTP Client for your PHP code. There's one here, for example.

John
+1  A: 

Hi, from within your php you can use HttpRequest::send http://usphp.com/manual/en/function.httprequest-send.php there are other options too like curl or others.

All of them has a kind of send() method, which will send the request and return the response to you. Than you can parse the response with XMLWriter or other.

+3  A: 

You could use the curl library to send the POST request: http://php.net/curl

Dominik
A: 

If all you need is make a simple POST request then no need to use complicated solutions based on curl. PHP streams will support it just fine.

$xml = file_get_contents(
    $url,
    null,
    stream_context_create(array(
        'http' => array(
            'method' => 'POST'
        )
    ))
);

Then you can use SimpleXML to read the XML.

Josh Davis