傳遞帶cURL的$POST值你怎么通過$_POST值到頁的cURL?
傳遞帶cURL的$POST值
幕布斯6054654
2019-08-03 15:03:50
TA貢獻1815條經驗 獲得超13個贊
$data = array('name' => 'Ross', 'php_master' => true);// You can POST a file by prefixing with an @ (for <input type="file">
fields)$data['file'] = '@/home/user/world.jpg';$handle = curl_init($url);curl_setopt($handle, CURLOPT_POST, true);c
url_setopt($handle, CURLOPT_POSTFIELDS, $data);curl_exec($handle);curl_close($handle)CURLOPT_POSTCURLOPT_POSTFIELDSPOST <form>
curl_setopt($handle, CURLOPT_POSTFIELDS, $data);
$dataarray()multipart/form-data
$data = array('name' => 'Ross', 'php_master' => true);curl_setopt($handle, CURLOPT_POSTFIELDS, $data);$dataapplication/x-www-form-urlencoded
$data = array('name' => 'Ross', 'php_master' => true);curl_setopt($handle, CURLOPT_POSTFIELDS, http_build_query($data));TA貢獻1780條經驗 獲得超1個贊
$xml = '<?xml version="1.0"?><stuff><child>foo</child><child>bar</child>
</stuff>';$httpRequest = curl_init();curl_setopt($httpRequest, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($httpRequest, CURLOPT_HTTPHEADER, array("Content-Type: text/xml"));
curl_setopt($httpRequest, CURLOPT_POST, 1);curl_setopt($httpRequest, CURLOPT_HEADER, 1);
curl_setopt($httpRequest, CURLOPT_URL, $url);curl_setopt($httpRequest, CURLOPT_POSTFIELDS, $xml);
$returnHeader = curl_exec($httpRequest);curl_close($httpRequest);CURLOPT_RETURNTRANSFERCURLOPT_HEADER.
舉報