且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

使用 HTTP POST 和 PHP 发送 XML 数据

更新时间:2022-06-02 22:22:44

你可以使用 cURL 库来发布数据:http://www.php.net/curl

you can use cURL library for posting data: http://www.php.net/curl

$ch = curl_init();
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
curl_setopt($ch, CURLOPT_URL, "http://websiteURL");
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, "XML=".$xmlcontent."&password=".$password."&etc=etc");
$content=curl_exec($ch);

其中 postfield 包含您需要发送的 XML - 您需要为 API 服务(我猜是 Clickatell)期望的 postfield 命名

where postfield contains XML you need to send - you will need to name the postfield the API service (Clickatell I guess) expects