Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Convert to 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--
like image 665
maa_ku Avatar asked Jul 28 '26 17:07

maa_ku


1 Answers

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

Edit: Didn't read all of post, fixed.

like image 110
Rawkode Avatar answered Jul 30 '26 07:07

Rawkode



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!