1
我將如何在PHP中使用此命令CURL
提交此test.xml
文件:將終端CURL轉換爲PHP CURL?
curl -X POST -k -d @test.xml -H "Content-Type: application/xml" --user username:password https://www.url.com
這不是爲我工作:
$ch = curl_init();
//Get the response from cURL
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
//Set the Url
curl_setopt($ch, CURLOPT_URL, 'https://username:[email protected]');
//Create a POST array with the file in it
$postData = array(
'testData' => '@test.xml',
);
curl_setopt($ch, CURLOPT_POSTFIELDS, $postData);
// Execute the request
$response = curl_exec($ch);
我也想知道我怎麼能提交XML編寫代碼而不是XML文件。
不把用戶名\密碼在url – 2016-11-10 20:52:23
是唯一的錯誤在我的代碼?以及我將如何傳遞用戶名和密碼 – Omar