我是新来的卷曲。我只想检查格式是否正确。我正进入(状态 错误就像是
解析错误:语法错误,以及/ 中的意外T_STRING for followinw curl命令
$curl="curl -i -X POST -d '{ "mac": ".$clientMAC.", "ap":".$ap.", "url": ".$url.", "session": { "email": ".$email.", "first_name": ".$fname.", ".$lname.": "user_last_name" } }' -H "Content-Type: text/html";
shell_exec($curl);
我该如何解决?请帮帮我
谢谢!
答案 0 :(得分:0)
我做了这个功能:
function makeCurlRequest($_url, $_data)
{
$curl = curl_init();
curl_setopt_array(
$curl,
array(
CURLOPT_RETURNTRANSFER => 1,
CURLOPT_URL => $_url,
CURLOPT_USERAGENT => 'Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.31 (KHTML, like Gecko) Chrome/26.0.1410.64 Safari/537.31',
CURLOPT_POST => 1,
CURLOPT_POSTFIELDS => $_data
));
$resp = curl_exec($curl);
curl_close($curl);
return $resp;
}
它将url和一个关联数组用于POST并返回结果