create_shared_url()
Create a preview url
create_preview_url()
Create a shared url for a file or folder and update its sharing permissions.
OneDrive Premium and Business accounts can request an expiring shared link or set a password.
Parameters
$id
string
ID of the entry
$param
array
Additional sharing permissions. Defaults to:
$param = [
'type' => 'view',
'scope' => 'anonymous',
];
Return
$url
string
The created shared link
Usage
WPCP_ONEDRIVE_API::set_account_by_id('8c9bacda0-d8d8-4b22-b634-7b5281687575');
WPCP_ONEDRIVE_API::set_drive_by_id('b!DlaHWskCed_MIid3KpJH5Lbatf9HsdXBAZH5YcvPAbMhJUKzTJyzgvXZYpBS');
$params = [
'type' => 'view',
'scope' => 'anonymous',
];
// Set password
// !!! Only available for OneDrive Business
$params['password'] = 'mypass1234';
// Set expire date
// !!! Only available for OneDrive Business
$expire_date = current_datetime()->modify('+1 month');
$params['unshared_at'] = $expire_date->setTimezone(new \DateTimeZone('UTC'))->format('Y-m-d\TH:i:s\Z');
// Create / Get shared links
$url = WPCP_ONEDRIVE_API::create_shared_url('01EXLSWHWMQZNDMLRG7NFIWAVYCFJAXP2R', $params);
Parameters
$id
string
ID of the entry
$params
array
Additional params for sharing permissions. Default:
$param = [
'role' => 'reader',
];
Return
$url
string
The created shared link
Usage
WPCP_GDRIVE_API::set_account_by_id('201096615285735764133')
$params = [
'role' => 'reader'
];
// Create / Get shared links
$url = WPCP_GDRIVE_API::create_shared_url('1wzWlDMsZkA4N5yEEAmMigp52u7M0Lk_7', $params);
Dropbox Pro, Business and Enterprise accounts can request e.g. read_only or password protected links.
Parameters
$id
string
ID of the entry
$param
array
Additional sharing permissions. Defaults to:
$param = [
'audience' => 'public',
'access' => 'viewer',
'expires' => null,
'require_password' => null,
'link_password' => null,
];
Return
$url
string
The created shared link
Usage
WPCP_DROPBOX_API::set_account_by_id('dbid:AADSy6JxzbgqCs4A43CAAAfO9xvZwpcsLU');
// Set password for link
// !!! Only available for Pro, Business
$params = [
'require_password' => true,
'link_password' => 'mypass1234',
];
// Set expire date
// !!! Only available for Pro, Business
$expire_date = current_datetime()->modify('+1 month');
$params['expires'] = $expire_date->setTimezone(new \DateTimeZone('UTC'))->format('Y-m-d\TH:i:s\Z');
// Create / Get shared links
$shared_links = WPCP_DROPBOX_API::create_shared_url('id:4tUAwPCAdf0b0AAAAA_iw', $params);
Box Pro, Business and Enterprise accounts can request an expiring shared link.
Parameters
$id
string
ID of the entry
$is_dir
bool
Is the entry a folder or a file?
$param
array
Additional sharing permissions. Defaults to:
$param = [
'access' => 'open',
'password' => null,
'permissions' => [
'can_download' => true,
],
'unshared_at' => null,
];
Return
$url
string
The created shared link
Usage
WPCP_BOX_API::set_account_by_id('29232154182');
// Set password for link
$params = [
'access' => 'open',
'password' => 'mypass1234',
];
// Set readonly link
$params['permissions']['can_download'] = false;
// Set expire date
// !!! Only available for Pro, Business
$expire_date = current_datetime()->modify('+1 month');
$params['unshared_at'] = $expire_date->format(DATE_RFC3339);
// Create / Get shared links
$shared_links = WPCP_BOX_API::create_shared_url('51142665', $params);
Last updated