【问题标题】:How to use Microsoft graph to get an url to an image in onedrive using php如何使用 Microsoft graph 使用 php 获取 onedrive 中图像的 url
【发布时间】:2023-01-13 16:03:48
【问题描述】:

我使用 Microsoft Graph 1.85 sdk for PHP 来管理 onedrive 帐户中的文件管理,在获得访问令牌后,我成功地使用此语法上传和下载文件

use Microsoft\Graph\Graph;
$graph = new Graph();
$graph->setAccessToken($user_accessToken);
// upload
$graph->createRequest("PUT", "/me/drive/root:/" . $folder_in_onedrive . $file . ":/content")->upload($uploadfile);
// download
 $graph->createRequest("GET", "/me/drive/root:/" . $folder_in_onedrive . $anotherfile . ":/content")->download($target_dir . $anotherfile);

现在我想在图形 api 中创建另一个请求类型 get sharing link 使用类型和范围参数,我在文档中知道请求应该是这样的:

$graph->createRequest("POST", "/me/drive/root:/" . $folder_in_onedrive . $file . ":/createLink")
/* Now im pretty sure d'ont know how to handle this type of request to get the url to the file in my case an image to display*/

【问题讨论】:

    标签: php api onedrive


    【解决方案1】:

    在图形示例和文档中进行搜索后,我设法得到了一个回复:

    $link = $graph->createRequest("POST", "/me/drive/root:/" . $folder_in_onedrive . $filename . ":/createLink")
        ->addHeaders(["Content-Type" => "application/json"])
        ->setReturnType( MicrosoftGraphModelSharingLink::class)
        ->execute();
    
        print_r($link);
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-08-13
      • 1970-01-01
      • 1970-01-01
      • 2020-07-30
      相关资源
      最近更新 更多