我是php&的新手。 cUrl所以我想知道是否有人知道如何使用php执行以下命令。
curl "http://www.mywebsite.com/index.php?action=confirm" -H "Origin: http://www.mywebsite.com" -H "User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/33.0.1750.154 Safari/537.36" -H "Content-Type: application/x-www-form-urlencoded" -H "Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8" -H "Cache-Control: max-age=0" -H "Referer: http://www.mywebsite.com/index.php?action=confirm" -H "Connection: keep-alive" --data "confirmed=yes&id=14&from=&to=TestPerson" --compressed
提前致谢,对不起,如果这是初学者的话。我只是想学习
答案 0 :(得分:2)
像这样改写..
<?php
$ch = curl_init();
$curlconf = array(
CURLOPT_URL => "http://www.mywebsite.com/index.php?action=confirm",
CURLOPT_POST => true,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_POSTFIELDS => array(
'confirmed' => 'yes',
'id' => 14,
'from'=>'',
'to'=>'TestPerson',
)
);
curl_setopt_array($ch, $curlconf);
$result = curl_exec($ch);
echo $result;
curl_close($ch);
答案 1 :(得分:1)