0

可能重复:
使用 PHP 将 XML 发布到 URL 并处理响应

有一个 XML 可以通过 POSTing 省 id 返回城市列表。(它通过 POST 接受 id) 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>

如何将省 ID(通过 POST REQUEST)发送到 XML?

我正在使用 php 5

4

1 回答 1

3

使用卷曲:

$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);
于 2012-10-26T08:36:28.560 回答