php Download OneDrive Item – how to Download OneDrive Item using rest api
in this post we will show you php Download OneDrive Item. For create onedrive folder you need register you app and get CLIENT-ID, CLIENT-SECRET and CALLBACK-URL.
For add CLIENT-ID, CLIENT-SECRET and CALLBACK-URL go to src/functions.inc.php. Pass CALLBACK-URL as example/callback.php
This is complete package for onedrive rest api using php ::
Download
php Download OneDrive Item suing rest api
Use this API we can download the contents for an item with the File facet.
Prerequisites Download a OneDrive Item contents using php
To call the OneDrive Item contents using php , the user must have granted/need the application read access to the file the app wishes to download.
How to revoke 'git add' before 'git commit' ?
In this post we will give you information about How to revoke 'git add' before 'git commit' ?. Hear we will give you detail about How to revoke 'git add' before 'git commit' ?And how to use it also give you demo for it if it is necessary.
Sometimes you need to undo your git file before you git comment command. Because you made a some misteck or wrong code and you did git add using "git add ." command then you think how to undo your code before git commit command. But you can do that using git reset command, if you need to undo all file Or you may need to undo just one then you can do using git reset command, you can see bellow command.
Example:
// For Spesific filegit reset
// For all files
git reset
Hope this code and post will helped you for implement How to revoke 'git add' before 'git commit' ?. if you need any help or any feedback give it in comment section or you have good idea about this post you can give it comment section. Your comment will help us for help you more and improve us. we will give you this type of more interesting post in featured also so, For more interesting post and code Keep reading our blogs
HTTP request for php Download OneDrive Item using rest api
GET /drive/items/{your-item-id}/content
GET /drive/root:/{path and filename}:/content
Example for php Download OneDrive Item using rest api
GET /drive/items/{your-item-id}/content
<?php
// code for Download OneDrive Item
// go to downlode package and include header.inc.php
require_once "header.inc.php";
// go to downlode package and in "src" folder and include functions.inc.php
require_once "../src/functions.inc.php";
// we Call this function to grab
// a current false or access_token if none this is available.
$get_token = skydrive_tokenstore::acquire_token();
if (!$get_token) {
echo "Error : token not found !!! Login or Try again.";
} else {
$onedrive_obj = new skydrive($get_token);
try {
$response_data = $onedrive_obj->download($_GET['fileid']);
ob_end_clean();
header('Content-Type: application/octet-stream');
header('Content-Length: '.$response_data[0]['properties']['size']);
header('Content-Description: File Transfer');
header('Content-Disposition: attachment; filename='.$response_data[0]['properties']['name']);
$std_out = fopen('php://output', 'r+');
fwrite($std_out, $response_data[0]['data']);
} catch (Exception $exception) {
// An error occured,
echo "Error for Download OneDrive Item :: ".$exception->getMessage();
exit;
}
}
require_once "footer.inc.php";
You may also like onedrive file upload using php