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 开发者_JAVA技巧I best send from my PHP request and then read the response. Thnkas.
You could use the curl library to send the POST request: http://php.net/curl
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.
You need a HTTP Client for your PHP code. There's one here, for example.
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.
精彩评论