我正在寻找通过php将文件上传到Microsoft OneDrive的代码示例。
我已经创建了一个Microsoft帐户并创建了一个应用程序。
谢谢分配
阿维
尝试使用https://github.com/lovattj/php-skydrive
上传示例:
<?php
require_once 'functions.inc.php';
$token = skydrive_tokenstore::acquire_token(); // Call this function to grab a current access_token, or false if none is available.
if (!$token) { // If no token, prompt to login. Call skydrive_auth::build_oauth_url() to get the redirect URL.
echo "<div>";
echo "<img src='statics/key-icon.png'> ";
echo "<a href='" . skydrive_auth::build_oauth_url() . "'>Login with SkyDrive</a></span>";
echo "</div>";
} else {
$sd = new skydrive($token);
try {
$response = $sd->put_file($_GET['folderid'], '/file/to/put');
// File was uploaded, return metadata.
print_r($response);
} catch (Exception $e) {
// An error occured, print HTTP status code and description.
echo "Error: ".$e->getMessage();
exit;
}
}
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句