如何使用Microsoft Graph Api从用户OneDrive显示文件 [英] How do i display files from a users OneDrive using the Microsoft Graph Api

查看:132
本文介绍了如何使用Microsoft Graph Api从用户OneDrive显示文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前正在使用OneDrive API从用户OneDrive获取文件.

I'm currently working with the OneDrive API to get files from a users OneDrive.

我需要能够根据用户单击的元素动态显示OneDrive中的文件.

I need to be able to display a file from OneDrive dynamically, depending on what element a user clicks on.

我知道我可以进入OneDrive并获得一个嵌入式链接,该链接可用于显示OneDrive中的文件,但这不是我所需要的.我尝试将嵌入式链接与数据绑定结合使用,但是该链接需要与初始嵌入式链接唯一的授权令牌.

I Know that I can go into my OneDrive and get a Embedded Link that I can use to display a file from my OneDrive, but this is not what I need. I attempted to use the Embedded Link combined with data binding but the link requires a authorization token unique the initial embedded link.

基本上,我希望用户单击与OneDrive元素相对应的元素(例如filepdf).然后,将在页面上的IFrame中显示文件.

Essentially I want a user to click on a element corresponding to a OneDrive element (eg a file or pdf). Then have file will display in a IFrame on the page.

推荐答案

这是在onedrive中创建编辑链接的示例,您可以将编辑类型更改为embeded以获取所需内容,这在php中利用laravel,带有文档 https://developer.microsoft.com/zh-CN/graph/docs/api-reference/v1.0/api/item_createlink

here is an example of a creation of an edit link in onedrive, you can change the type of edit to embeed to get what you want, this is in php utilizing laravel, the graph api with the docs https://developer.microsoft.com/en-us/graph/docs/api-reference/v1.0/api/item_createlink

公共函数getEditableEmbeed($ itemid){

public function getEditableEmbeed($itemid){

    $this->refresh();
     $file = $this->getGraph()->createRequest("POST", "/me/drive/items/".$itemid."/createLink")->attachBody('{ "type": "edit", "scope": "anonymous"}')->execute();
     return $file;
}

这篇关于如何使用Microsoft Graph Api从用户OneDrive显示文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆