有人可以帮助我在PHP CURL中形成以下POST请求吗?
如此网址所述:https://developer.amazon.com/public/apis/experience/cloud-drive/content/nodes
curl -v -X POST --form
'metadata={"name":"testVideo1","kind":"FILE"}' --form
'content=@sample_iTunes.mp4'
'https://content-na.drive.amazonaws.com/cdproxy/nodes?localId=testVideo1&suppress=deduplication'
--header "Authorization: Bearer
Atza|IQEBLjAsAhQ5zx7pKp9PCgCy6T1JkQjHHOEzpwIUQM"
这是我正在尝试...我想形成上面提到的类型卷曲请求到亚马逊服务器,所以我可以上传一个文件。由于没有可用的例子,我可以帮忙吗?
$fields = array(
'multipart' => array(
'name' => 'testupload',
'content' => array(
'kind' => 'FILE',
'name' => 'hi.jpg',
'parents' => $parents
)
)
);
$fields_string = json_encode($fields);
//open connection
$ch = curl_init();
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_HTTPHEADER, $contenttype);
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_HEADER, 1);
curl_setopt($ch, CURLOPT_POST, count($fields));
curl_setopt($ch, CURLOPT_POSTFIELDS, $fields_string);
$result = curl_exec($ch);
$httpstatus = curl_getinfo($ch, CURLINFO_HTTP_CODE);
答案 0 :(得分:0)
你快到了。
在卷曲代码上添加此内容。
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE);
这将能够使用SSL / HTTPS访问网址。