1

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

csrf 检查失败

我的 curl 请求如下。

$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);

请我在这个问题上需要帮助。提前致谢!

4

1 回答 1

1

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

All calls to OCS endpoints require the OCS-APIRequest header to be set to true.

Adding the header does the trick.

于 2018-01-24T10:50:35.393 回答