Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/262.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php Microsoft Graph API-无法打开上载的文件_Php_Microsoft Graph Api_Guzzle - Fatal编程技术网

Php Microsoft Graph API-无法打开上载的文件

Php Microsoft Graph API-无法打开上载的文件,php,microsoft-graph-api,guzzle,Php,Microsoft Graph Api,Guzzle,我正在尝试使用Microsoft Graph API上载文件。它似乎上传OK,但当试图打开文件时,我被告知它无法打开 下面是我的PHP代码的相关部分。我一直在用狂饮来提出要求 $data = file_get_contents($_FILES['foo']['tmp_name']); $guzzle = new GuzzleHttp\Client(); $sent_options = [ 'headers' => [ 'Authorization' =>

我正在尝试使用Microsoft Graph API上载文件。它似乎上传OK,但当试图打开文件时,我被告知它无法打开

下面是我的PHP代码的相关部分。我一直在用狂饮来提出要求

$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);

好的,我已经解决了。。。对于其他有同样问题的人,这里有一个解决方案

$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);