1
cURLを使用してOneDrive Business ACアカウントの新しいフォルダにJSONファイルをアップロードしようとしています。アップロード中に、私は次のエラーを取得しています:ここでPHP-Curlを使用してOffice 365 Onedrive Businessアカウントにファイルをアップロード
HTTP status code not expected - got - 401
は私のコードです:
$headers = array('Content-Type: application/text', "Cache-Control: no-cache", "Pragma: no-cache", "Authorization: bearer ".$token);
とパス:
$uri = "https://graph.microsoft.com/v1.0/me/drive/root/new/sample.json/content?access_token=accesstoken";
function curl_put($uri, $fp) {
$output = "";
try {
$pointer = fopen($fp, 'r+');
$stat = fstat($pointer);
$pointersize = $stat['size'];
$ch = curl_init($uri);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'PUT');
curl_setopt($ch, CURLOPT_PUT, true);
curl_setopt($ch, CURLOPT_INFILE, $pointer);
curl_setopt($ch, CURLOPT_INFILESIZE, (int) $pointersize);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_TIMEOUT, 60);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 2);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt($ch, CURLOPT_FRESH_CONNECT, TRUE);
}
}
有益な回答ありがとうございます。 –