create_edit_url()

Create a edit url

create_edit_url()

Create an url to an editable view of the file. By default, a public shared link will be created.

OneDrive Premium and Business accounts can request an expiring shared link or set a password.

Parameters

Name
Type
Description

$id

string

ID of the entry

$param

array

Additional sharing permissions. Defaults to:

$param = [
  'type' => 'edit',
  'scope' => 'anonymous',
];

Return

Name
Type
Description

$url

string

The created 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' => 'edit',
    '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_edit_url('01EXLSWHWMQZNDMLRG7NFIWAVYCFJAXP2R', $params);

Last updated