Closed opasgruz closed 3 years ago
I am found the solution. But Guzzle still not working. $ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'https://cloud.er.ru/ocs/v2.php/apps/files_sharing/api/v1/shares');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, "path=/folder.jpg&shareType=3&permissions=1");
curl_setopt($ch, CURLOPT_USERPWD, {username} . ':' . {password});
$headers = array();
$headers[] = 'Ocs-Apirequest: true';
$headers[] = 'Content-Type: application/x-www-form-urlencoded';
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
$result = curl_exec($ch);
if (curl_errno($ch)) {
echo 'Error:' . curl_error($ch);
}
curl_close($ch);
dd($result);exit;
Hi, please ask your question here: https://help.nextcloud.com/c/dev/11 Thanks!
I am try to share existing file on NextCloud server. This is not my server, i have only access to account and API. NextCloud server version 19.0.2. I am using new API without examples https://docs.nextcloud.com/server/stable/developer_manual/client_apis/OCS/ocs-share-api.html#create-a-new-share and old API with examples https://doc.owncloud.com/server/developer_manual/core/apis/ocs-share-api.html#create-a-new-share. After this request i recived statusCode 200 (it must be 100, 400, 403 or 404 on API documentation ) and file is not shared. use GuzzleHttp\Client as Client;
Response: GuzzleHttp\Psr7\Response {#1844 ▼ -reasonPhrase: "OK" -statusCode: 200 -headers: array:21 [▶] -headerNames: array:21 [▶] -protocol: "1.1" -stream: GuzzleHttp\Psr7\Stream {#1842 ▶} }