curl 下一个云操作系统创建共享API权限问题

nimxete2  于 2022-11-13  发布在  其他
关注(0)|答案(1)|浏览(137)

在ocs共享api的帮助下创建共享链接时,我可以创建链接,但它没有设置我试图给予它的权限。

$ch = curl_init("https://servername/ocs/v2.php/apps/files_sharing/api/v1/shares");
        curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: multipart/form-data', "OCS-APIRequest:true"));
        curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
        curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
        curl_setopt($ch, CURLOPT_USERPWD, getenv('NEXTCLOUDUSERNAME') . ":" . getenv('NEXTCLOUDPASSWORD'));
        curl_setopt($ch, CURLOPT_TIMEOUT, 30);
        curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
        curl_setopt($ch, CURLOPT_POSTFIELDS, $_POST);
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
        $return = curl_exec($ch);
bprjcwpo

bprjcwpo1#

function curlPost($url, $headers, $username, $password, $data) {
     $ch = curl_init();
     curl_setopt($ch, CURLOPT_URL, $url);
     curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
     curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
     curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
     curl_setopt($ch, CURLINFO_HEADER_OUT, true);
     curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
     curl_setopt($ch, CURLOPT_USERPWD, $username . ":" . $password);
     curl_setopt($ch, CURLOPT_TIMEOUT, 30);
     curl_setopt($ch, CURLOPT_POST, 1);
     curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
     curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
     return curl_exec($ch);
     curl_close($ch);
}

$url = 'https://SERVERNAME/ocs/v2.php/apps/files_sharing/api/v1/shares';
$headers = Array('OCS-APIRequest: true');
$username = 'NEXTCLOUDUSERNAME';
$password = 'NEXTCLOUDPASSWORD';
$data = 'path=PATH/FILE.xxx&shareType=3&permissions=1&format=json';
echo curlPost($url, $headers, $username, $password, $data);

相关问题