Move, copy, create, or delete a file or folder on OneDrive REST api using php
To move a folder, file, photo, video, or audio, use code like this on OneDrive REST api using php. The wl.skydrive_update scope is needed. The supply are often something except the foundation, and also the destination should be the folder to that the item are going to be affected. modification file ID to the file ID or folder ID of the file or folder you would like to maneuver. modification the folder ID to the folder ID of the destination folder.
After Signing users in with REST and getting Get an access token and an authentication token do following process.
Note
The destination of a move operation should be a folder. Also, OneDrive storage is structured so move operations cannot occur between the OneDrive folder hierarchies of various users. for instance, although user A will browse user B’s files, user A cannot move them to his or her own OneDrive folders.
To copy a file, replace MOVE with COPY within the example. The wl.skydrive_update scope is needed. modification file ID to the file ID of the file you would like to repeat. modification the folder ID to the folder ID of the destination folder.
Note
The destination of a duplicate operation should be a folder. Folders themselves can not be derived. Also, OneDrive storage is structured so copy operations cannot occur between the OneDrive folder hierarchies of various users. for instance, although user A will browse user B’s files, user A cannot copy them to his or her own OneDrive folders.
MOVE !126 // pass data in header Authorization: Bearer ACCESS_TOKEN Content-Type: application/json // pass data { "destination": "folder.ai8d47e8fdefge5e.ai8d47e8fdefge5e!114" }
Delete a file on OneDrive REST api using php
To Delete a file on OneDrive REST api using php, photo, video, or audio, use code like this. The wl.skydrive_update scope is needed. modification the file ID to a different file ID, photo ID, video ID, or audio ID to remove a different file, photo, video, or audio.
DELETE // pass ACCESS_TOKEN !225?access_token=ACCESS_TOKEN
Create a folder on OneDrive REST api using php
To add a new folder on OneDrive REST api using php, use code like this. The wl.skydrive_update scope is need. Change me or skydrive to the folder ID (or, in certain cases, the friendly names) of the folder in which the new folder will be created in OneDrive.
For details about the minimum required and optional structures that your app must provide to use POST, see the Folder object.
POST https://apis.live.net/v5.0/me/skydrive // pass data in header Authorization: Bearer ACCESS_TOKEN Content-Type: application/json // pass data { "name": "this_is_my_example_folder" }
Delete a folder on OneDrive REST api using php
To remove a folder on OneDrive REST api using php, using this code. The wl.skydrive_update scope is required.
// pass data ACCESS_TOKEN DELETE !114?access_token=ACCESS_TOKEN
Get an inventory of the user’s last used documents on OneDrive REST api using php
To get an inventory of OneDrive documents that the user has used last n OneDrive REST api using php, use the wl.skydrive scope to form a GET request to /USER_ID/skydrive/recent_docs, wherever USER_ID is either me or the user ID of the willing user. Here’s example.
// pass data ACCESS_TOKEN GET https://apis.live.net/v5.0/me/skydrive/recent_docs?access_token=ACCESS_TOKEN
Traverse the OneDrive directory on OneDrive REST api using php
To use the Live SDK to induce information a few user’s ranking folder within the OneDrive directory, you create a GET request to me/skydrive or USER_ID/skydrive.
In the JavaScript Object Notation (JSON)-formatted object that is returned, 2 structures ar vital to note: the id structure that represents the ranking folder’s folder ID, and therefore the transfer_location structure that represents the placement for the ranking folder to that you’ll upload files, photos, videos, and audio.
If you create asking to me/skydrive/files or USER_ID/skydrive/files, the JSON-formatted object that is came contains information concerning all of the kid folders, kid albums, and files within the user’s ranking folder only.
From there, you’ll traverse a user’s entire OneDrive directory by creating asking with FOLDER_ID/files or ALBUM_ID/files, wherever FOLDER_ID or ALBUM_ID represents the id structure that corresponds to a folder ID or album ID, severally, anyplace within the directory.
As with a user’s ranking OneDrive folder, you’ll use the upload_location structure for any folder or album to upload files thereto folder or album. in addition, you’ll use the upload_location structure for any file, photo, video, or audio to write the contents of that file, photo, video, or audio.
// pass data ACCESS_TOKEN GET https://apis.live.net/v5.0/me/skydrive?access_token=ACCESS_TOKEN --- // give result 200 OK { "id": "folder.ai8d47e8fdefge5e", ... "upload_location": "https://apis.live.net/v5.0/folder.ai8d47e8fdefge5e/files", ... "type": "folder", ... } // pass data ACCESS_TOKEN GET https://apis.live.net/v5.0/folder.ai8d47e8fdefge5e/files?access_token=ACCESS_TOKEN // give result 200 OK { "data": [ { "id": "folder.ai8d47e8fdefge5e.ai8d47e8fdefge5e!110", ...... "upload_location": "https://apis.live.net/v5.0/folder.ai8d47e8fdefge5e.ai8d47e8fdefge5e!110/files/" ...... "type": "folder", ...... }, { "id": "photo.ai8d47e8fdefge5e.ai8d47e8fdefge5e!131", ...... "upload_location": "https://apis.live.net/v5.0/photo.ai8d47e8fdefge5e.ai8d47e8fdefge5e!131/content/", ...... "type": "photo", ...... }, { "id": "file.ai8d47e8fdefge5e.ai8d47e8fdefge5e!119", ...... "upload_location": "https://apis.live.net/v5.0/file.ai8d47e8fdefge5e.ai8d47e8fdefge5e!119/content/", ...... "type": "file", ...... } ] }
Display a preview of a OneDrive item on OneDrive REST api using php
To display a preview of an item in OneDrive, make a GET request to /skydrive/get_item_preview?type=TYPE&url=URL. The optional type query-string parameter is one of the following:
thumbnail
small (to get a maximum 100*100-pixel preview)
album (maximum 200*200)
normal (maximum 800*800)
The required url query-string parameter could be a shared link to the item in OneDrive. Here are 2 examples, one using a longer OneDriveURL and one using a shorter sdrv.ms url (sdrv.ms is a URL-shortening service that is unique to OneDrive).
GET !132%26amp%3Bparid%3DA6B2A7E8F2515E5E!110%26amp%3Bauthkey%3D!ACuMMo37Ju8_xw0x
GET
Note the following:
To make the get_item_preview request, you do not got to request any scopes or give an access token.
If the item isn’t a photograph, and a preview is related to the item, a fingernail preview is displayed and therefore the sort parameter is neglected even though provided.
A thriving response includes a responseStatus price of” 302 Found” with the link to the item preview within the “Location” response header.
If a selected size of preview does not exist, the next-largest size preview that is accessible is displayed. If no preview is related to the item, a 404 (Not Found) error is came back.
You can get a shared link to an item in one in all 3 ways:
Make a GET request to ITEM_ID/shared_read_link, wherever ITEM_ID is that the OneDrive item’s ID. Here’s an example.
// pass data ACCESS_TOKEN GET !131/shared_read_link?access_token=ACCESS_TOKEN
You can realize the shared link price within the JavaScript Object Notation (JSON)-formatted response object’s link structure.
In the OneDriveUI, choose the item, and so click Share. Click Get a link and so, next to view solely, click produce. OneDrive displays the shared link price, that you’ll be able to use in your get_item_preview request. the worth ought to look one thing like this:
// pass data authkey !132&parid=ai8d47e8fdefge5e!110&authkey=!ACuMMo37Ju8_xw0x.
In the OneDriveUI, choose the item, and so click Share. Click Post to Twitter, follow the on-screen directions, and so click Post. The new created Twitter post includes the shared link price, that you’ll be able to use in your get_item_preview request. the worth ought to look one thing like this: .
The url query-string parameter’s price should be URL-encoded. for instance, use %3A for the colon (“:”) character, %2F for the forward slash (“/”) character, %3F for the punctuation mark (“?”) character, and 26 for the punctuation mark (“&”) character.