本文整理汇总了PHP中Rest::create_multipart方法的典型用法代码示例。如果您正苦于以下问题:PHP Rest::create_multipart方法的具体用法?PHP Rest::create_multipart怎么用?PHP Rest::create_multipart使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Rest
的用法示例。
在下文中一共展示了Rest::create_multipart方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: post_resource_multipart
public static function post_resource_multipart($uri, $data)
{
$auth_uri = Authentication::prepare_authenticated_uri($uri);
$ch = curl_init($auth_uri);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
// do a multipart upload
$dataarr = Rest::create_multipart($data);
$headers = $dataarr["headers"];
$content = $dataarr["content"];
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_POSTFIELDS, $content);
curl_setopt($ch, CURLOPT_HEADER, true);
$response = curl_exec($ch);
$info = curl_getinfo($ch);
curl_close($ch);
// return the content location header
if ($info['http_code'] == 201) {
$parsed = Rest::parse_http_response($response);
return array("success" => true, "status-code" => $info['http_code'], "data" => $parsed[0]['content-location']);
} else {
return array("success" => false, "status-code" => $info['http_code'], "data" => null);
}
}