0

Possible Duplicate:
POST XML to URL with PHP and Handle Response

There is an XML to return city list by POSTing province id. (it accepts the id by POST) http://example.com/get_city_list.xml

<cities>
  <city>
    <id></id>
    <name></name>
  </city>

  <city>
    <id></id>
    <name></name>
  </city>

  <city>
    <id></id>
    <name></name>
  </city>
<cities>

How can I send out the province id (by POST REQUEST) to the XML?

I am using php 5

Community
  • 1
  • 1
gilzero
  • 1,832
  • 4
  • 19
  • 26

1 Answers1

3

Use CURL:

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "http://www.example.com/path/to/form");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POST, true);

$data = array(
    'foo' => 'foo foo foo',
    'bar' => 'bar bar bar',
    'baz' => 'baz baz baz'
);

curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
$output = curl_exec($ch);
$info = curl_getinfo($ch);
curl_close($ch);
Vyacheslav Voronchuk
  • 2,403
  • 19
  • 16