我正在尝试发布一个使用 SharePoint 和 PHP 的 ASPX 表单。
发布数据适用于标准表格,我似乎无法让这个表格工作。我确实注意到onclick
提交按钮上的一个属性:
onclick="javascript:WebForm_DoPostBackWithOptions(new WebForm_PostBackOptions("ctl00$PlaceHolderMain$btnSaveTask", "", true, "", "", false, false))"
我从未使用过 ASPX,也不知道这是什么。这不是身份验证问题或 url 有问题,因为它可以正常返回网页(包含表单)。
这是我的PHP代码:
function add($username, $password){
$data = array(
'ctl00$PlaceHolderSearchArea$ctl01$ctl00' => 'https://keystone.stpeters.sa.edu.au',
'ctl00$PlaceHolderSearchArea$ctl01$ctl04' => '0',
'ctl00$PlaceHolderMain$DateStart$DateStartDate' => '9/05/2012',
'ctl00$PlaceHolderMain$DateDue$DateDueDate' => '10/05/2012',
'ctl00$PlaceHolderMain$Title' => 'test again',
'ctl00$PlaceHolderMain$btnSaveTask' => 'OK',
'__spText1' => '',
'__spText2' => ''
);
$curl_handle = curl_init();
$fullurl = "https://keystone.stpeters.sa.edu.au/_layouts/StPeters.Keystone/MyTasks/MyTaskDetail.aspx?id=0&IsDlg=1"; //
$ch = curl_init();
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_VERBOSE, 1);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($ch, CURLOPT_FAILONERROR, 0);
curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_ANY);
curl_setopt($ch, CURLOPT_USERPWD, "$username:$password");
curl_setopt($ch, CURLOPT_URL, $fullurl);
$returned = curl_exec($ch);
curl_close ($ch);
return $returned;
}