我尝试通过cURL填写HTML表单。通常,我会根据相应的表格等效来传递变量。例如。
<input name='prename'>
但是远程表单是使用angularJS创建的,因此输入字段没有名称属性:
<input type="text" placeholder="your prename" ng-model="prename" force-selection="true" ng-model-options="{ debounce: 200 }">
所以,这不起作用:
function curlStart($domain, $var = false)
{
global $sCurlResult;
$fp = curl_init($domain);
curl_setopt($fp,CURLOPT_TIMEOUT,10);
curl_setopt($fp,CURLOPT_FAILONERROR,1);
curl_setopt($fp,CURLOPT_RETURNTRANSFER,1);
curl_setopt($fp, CURLOPT_SSL_VERIFYPEER, false);
if($var != false)
{
curl_setopt($fp,CURLOPT_POST,1);
curl_setopt ($fp, CURLOPT_POSTFIELDS, $var);
}
$sCurlResult = curl_exec($fp);
if(curl_errno($fp) != 0)
{
$send = FALSE;
}
else
{
$send = TRUE;
}
curl_close($fp);
return $send;
}
$formURL = 'https://urlofremoteform';
$var = 'prename=John;
$send = curlStart($formURL,$var);
如何将值“John”传递给prename的输入字段?