OneDrive Filepicker SDK可用于获取文件载你可以用以显示如共享的链接或下载文件。 这里是步骤设置OneDrive FilePicker 步骤1: 登记册应用在 https://apps.dev.microsoft.com/ 使用一个重定向网址的网页上有你的网站(你会需要加入OneDrive.js 在这页)。 之后注册程序,你会得到应用标识。 步骤2: 文档文件,picker如下: <script type="text/javascript" src="https://js.live.net/v7.2/OneDrive.js" async="async"></script> <script type="text/javascript"> launchOneDrivePicker = function(that) { var odOptions = { clientId: "YOUR_APPLICATION_ID", action: "query", multiSelect: false, advanced: { redirectUri: "https://yourCommonRedirectUri.com", }, openInNewWindow: true, success: function(response) { $.each(response.value, function(index, value) { var url = response.apiEndpoint + 'drives/' + value.parentReference.driveId + '/items/' + value.id; $.ajax({ 'url': url, beforeSend: function(request) { request.setRequestHeader("Authorization", 'Bearer ' + response.accessToken); }, success: function(result) { // console.log(result); var resultData = { 'url': result['@microsoft.graph.downloadUrl'], // this returns shareable url of file 'name': result['name'], // this returns file name }; }, error: function(xhr) { }, }); }); }, cancel: function() { // called when user cancels popup action }, error: function(e) { // called when error in connecting to OneDrive api } }; OneDrive.open(odOptions); //launches file picker }; </script> 12345678910111213141516171819202122232425262728293031323334353637383940414243 <script type="text/javascript" src="https://js.live.net/v7.2/OneDrive.js" async="async"></script> <script type="text/javascript"> launchOneDrivePicker = function(that) { var odOptions = { clientId: "YOUR_APPLICATION_ID", action: "query", multiSelect: false, advanced: { redirectUri: "https://yourCommonRedirectUri.com", }, openInNewWindow: true, success: function(response) { $.each(response.value, function(index, value) { var url = response.apiEndpoint + 'drives/' + value.parentReference.driveId + '/items/' + value.id; $.ajax({ 'url': url, beforeSend: function(request) { request.setRequestHeader("Authorization", 'Bearer ' + response.accessToken); }, success: function(result) { // console.log(result); var resultData = { 'url': result['@microsoft.graph.downloadUrl'], // this returns shareable url of file 'name': result['name'], // this returns file name }; }, error: function(xhr) { }, }); }); }, cancel: function() { // called when user cancels popup action }, error: function(e) { // called when error in connecting to OneDrive api } }; OneDrive.open(odOptions); //launches file picker }; </script> 注意到: 你可以使用单一重定向URL而不是多个当使用文件的选择器在许多网页。 界定先进的选项,如: advanced: { redirectUri: "https://yourCommonRedirectUri.com", }, 123 advanced: { redirectUri: "https://yourCommonRedirectUri.com", }, 这里是正式文件和有用的链接、编辑文件的选择器: https://dev.onedrive.com/sdk/js-v72/js-picker-open.htm https://github.com/OneDrive/onedrive-api-docs Tag(s) filepicker OneDrive