沃梦达 / 编程问答 / php问题 / 正文

转换为 PHP REST CURL POST

Convert to PHP REST CURL POST(转换为 PHP REST CURL POST)

本文介绍了转换为 PHP REST CURL POST的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们如何将此代码转换为 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.

这篇关于转换为 PHP REST CURL POST的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!

本文标题为:转换为 PHP REST CURL POST

基础教程推荐