转换为 PHP REST CURL POST

2022-01-09 00:00:00 rest onedrive post upload php

我们如何将此代码转换为 PHP REST CURL POST?

How can we convert this code to PHP REST CURL POST?

POST https://apis.live.net/v5.0/me/skydrive/files?access_token=ACCESS_TOKEN

Content-Type: multipart/form-data; boundary=A300x

--A300x
Content-Disposition: form-data; name="file"; filename="HelloWorld.txt"
Content-Type: application/octet-stream

Hello, World!
--A300x--

推荐答案

$url = 'POST https://apis.live.net/v5.0/me/skydrive/files';
$ch = curl_init();
curl_setopt($ch,CURLOPT_URL, $url);
curl_setopt($ch,CURLOPT_POSTFIELDS, array('access_token' => TOKEN, 'name' => 'file', 'filename' => "@HelloWorld.txt"));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$result = curl_exec($ch);
curl_close($ch);

未阅读所有帖子,已修复.

Didn't read all of post, fixed.

相关文章