本文整理汇总了PHP中S3::__get_signature方法的典型用法代码示例。如果您正苦于以下问题:PHP S3::__get_signature方法的具体用法?PHP S3::__get_signature怎么用?PHP S3::__get_signature使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类S3
的用法示例。
在下文中一共展示了S3::__get_signature方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: get_response
/**
* Get the S3 response
*
* @return object | false
*/
public function get_response()
{
$query = '';
if (sizeof($this->parameters) > 0) {
$query = substr($this->uri, -1) !== '?' ? '?' : '&';
foreach ($this->parameters as $var => $value) {
if ($value == null || $value == '') {
$query .= $var . '&';
} else {
$query .= $var . '=' . rawurlencode($value) . '&';
}
}
$query = substr($query, 0, -1);
$this->uri .= $query;
if (array_key_exists('acl', $this->parameters) || array_key_exists('location', $this->parameters) || array_key_exists('torrent', $this->parameters) || array_key_exists('logging', $this->parameters)) {
$this->resource .= $query;
}
}
$url = (S3::$use_ss_l && extension_loaded('openssl') ? 'https://' : 'http://') . $this->headers['Host'] . $this->uri;
//var_dump($this->bucket, $this->uri, $this->resource, $url);
// Basic setup
$curl = curl_init();
curl_setopt($curl, CURLOPT_USERAGENT, 'S3/php');
if (S3::$use_ss_l) {
curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, 1);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, 1);
}
curl_setopt($curl, CURLOPT_URL, $url);
// Headers
$headers = array();
$amz = array();
foreach ($this->amz_headers as $header => $value) {
if (strlen($value) > 0) {
$headers[] = $header . ': ' . $value;
}
}
foreach ($this->headers as $header => $value) {
if (strlen($value) > 0) {
$headers[] = $header . ': ' . $value;
}
}
// Collect AMZ headers for signature
foreach ($this->amz_headers as $header => $value) {
if (strlen($value) > 0) {
$amz[] = strtolower($header) . ':' . $value;
}
}
// AMZ headers must be sorted
if (sizeof($amz) > 0) {
sort($amz);
$amz = "\n" . implode("\n", $amz);
} else {
$amz = '';
}
// Authorization string (CloudFront string_To_Sign should only contain a date)
$headers[] = 'Authorization: ' . S3::__get_signature($this->headers['Host'] == 'cloudfront.amazonaws.com' ? $this->headers['Date'] : $this->verb . "\n" . $this->headers['Content-MD5'] . "\n" . $this->headers['Content-Type'] . "\n" . $this->headers['Date'] . $amz . "\n" . $this->resource);
curl_setopt($curl, CURLOPT_HTTPHEADER, $headers);
curl_setopt($curl, CURLOPT_HEADER, false);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, false);
curl_setopt($curl, CURLOPT_WRITEFUNCTION, array(&$this, '__response_write_callback'));
curl_setopt($curl, CURLOPT_HEADERFUNCTION, array(&$this, '__response_header_callback'));
curl_setopt($curl, CURLOPT_FOLLOWLOCATION, true);
// Request types
switch ($this->verb) {
case 'GET':
break;
case 'PUT':
case 'POST':
// POST only used for Cloud_Front
if ($this->fp !== false) {
curl_setopt($curl, CURLOPT_PUT, true);
curl_setopt($curl, CURLOPT_INFILE, $this->fp);
if ($this->size >= 0) {
curl_setopt($curl, CURLOPT_INFILESIZE, $this->size);
}
} elseif ($this->data !== false) {
curl_setopt($curl, CURLOPT_CUSTOMREQUEST, $this->verb);
curl_setopt($curl, CURLOPT_POSTFIELDS, $this->data);
if ($this->size >= 0) {
curl_setopt($curl, CURLOPT_BUFFERSIZE, $this->size);
}
} else {
curl_setopt($curl, CURLOPT_CUSTOMREQUEST, $this->verb);
}
break;
case 'HEAD':
curl_setopt($curl, CURLOPT_CUSTOMREQUEST, 'HEAD');
curl_setopt($curl, CURLOPT_NOBODY, true);
break;
case 'DELETE':
curl_setopt($curl, CURLOPT_CUSTOMREQUEST, 'DELETE');
break;
default:
break;
}
//.........这里部分代码省略.........