nextcloude api中的csrf检查失败

时间:2018-01-10 06:37:25

标签: php curl nextcloud

我在php中使用curl请求在nextcloude中调用用户注册api 但我得到了以下回应。

csrf检查失败

我的卷曲请求如下。

$ownAdminname=“xxxx”;
$ownAdminpassword=“xxx”;

$ ownconnect =“https://开头 “$ ownAdminname ”:“。。$ ownAdminpassword” @ local.ngageapp.com”;

$username=‘xxxx’;
$password=‘xxx’;
$url = “{$ownconnect}/ocs/v1.php/cloud/users”;
$ownCloudPOSTArray = array(‘userid’ => $username, ‘password’ => $password );
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $ownCloudPOSTArray);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_USERPWD, $ownAdminname.":".$ownAdminpassword);
$response = curl_exec($ch);
curl_close($ch);

我需要帮助解决这个问题。提前谢谢!

1 个答案:

答案 0 :(得分:0)

来自https://docs.nextcloud.com/server/12/admin_manual/configuration_user/user_provisioning_api.html

  

对OCS端点的所有调用都要求将OCS-APIRequest标头设置为true。

添加标题就可以了。