【问题标题】:Microsoft Graph API - Uploaded file can not be openedMicrosoft Graph API - 无法打开上传的文件
【发布时间】:2018-06-04 21:10:01
【问题描述】:

我正在尝试使用 Microsoft Graph API 上传文件。好像可以上传了,但是打开文件时提示无法打开。

这是我的 PHP 代码的相关部分。我使用 Guzzle 发出请求。

$data = file_get_contents($_FILES['foo']['tmp_name']);

$guzzle = new GuzzleHttp\Client();

$sent_options = [
    'headers' => [
        'Authorization' => 'Bearer ' . $accessToken,
        'Content-Type'  => 'text/plain'
    ],
    'form_params' => [
        base64_encode($data)
    ]
];

$guzzle->put($url, $sent_options);

【问题讨论】:

    标签: php microsoft-graph-api guzzle


    【解决方案1】:

    好的,所以我已经解决了......对于其他有同样问题的人,这是解决方案。

    $data = file_get_contents($_FILES['foo']['tmp_name']);
    
    $guzzle = new GuzzleHttp\Client();
    
    $sent_options = [
        'headers' => [
            'Authorization' => 'Bearer ' . $accessToken,
            'Content-Type'  => 'text/plain'
        ],
        'body' => $data
    ];
    
    $guzzle->put($url, $sent_options);
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2018-04-12
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2022-10-04
      • 2019-12-03
      • 1970-01-01
      相关资源
      最近更新 更多