facebook twitter hatena line email

Php/curl/xml送信

提供: 初心者エンジニアの簡易メモ
移動: 案内検索
$xmltag = <<< EOD
<?xml version="1.0" encoding="UTF-8"?>
<root><id>2</id><name>taro</name></root>
EOD;
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: text/xml'));
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $xmltag);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$result = curl_exec($ch);
curl_close($ch);