本文整理汇总了PHP中Qiniu_Client_CallWithForm函数的典型用法代码示例。如果您正苦于以下问题:PHP Qiniu_Client_CallWithForm函数的具体用法?PHP Qiniu_Client_CallWithForm怎么用?PHP Qiniu_Client_CallWithForm使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了Qiniu_Client_CallWithForm函数的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: Qiniu_PutFile
function Qiniu_PutFile($upToken, $key, $localFile, $putExtra)
{
global $QINIU_UP_HOST;
if ($putExtra === null) {
$putExtra = new Qiniu_PutExtra();
}
$fields = array('token' => $upToken, 'file' => createFile($localFile, $putExtra->MimeType));
if ($key !== null) {
$fields['key'] = $key;
}
if ($putExtra->CheckCrc) {
if ($putExtra->CheckCrc === 1) {
$hash = hash_file('crc32b', $localFile);
$array = unpack('N', pack('H*', $hash));
$putExtra->Crc32 = $array[1];
}
$fields['crc32'] = sprintf('%u', $putExtra->Crc32);
}
if ($putExtra->Params) {
foreach ($putExtra->Params as $k => $v) {
$fields[$k] = $v;
}
}
$client = new Qiniu_HttpClient();
return Qiniu_Client_CallWithForm($client, $QINIU_UP_HOST, $fields, 'multipart/form-data');
}
示例2: Qiniu_PutFile
function Qiniu_PutFile($upToken, $key, $localFile, $putExtra)
{
global $QINIU_UP_HOST;
if ($putExtra === null) {
$putExtra = new Qiniu_PutExtra();
}
if (!empty($putExtra->MimeType)) {
$localFile .= ';type=' . $putExtra->MimeType;
}
$fields = array('token' => $upToken, 'file' => '@' . $localFile);
if ($key === null) {
$fname = '?';
} else {
$fname = $key;
$fields['key'] = $key;
}
if ($putExtra->CheckCrc) {
if ($putExtra->CheckCrc === 1) {
$hash = hash_file('crc32b', $localFile);
$array = unpack('N', pack('H*', $hash));
$putExtra->Crc32 = $array[1];
}
$fields['crc32'] = sprintf('%u', $putExtra->Crc32);
}
$client = new Qiniu_HttpClient();
return Qiniu_Client_CallWithForm($client, $QINIU_UP_HOST, $fields, 'multipart/form-data');
}
示例3: MakeRequest
public function MakeRequest($self)
{
global $QINIU_API_HOST;
$ReqParams = array('bucket' => $this->Bucket, 'key' => $this->Key, 'fops' => $this->Fops, 'notifyURL' => $this->NotifyURL, 'force' => $this->Force, 'pipeline' => $this->Pipeline);
$url = $QINIU_API_HOST . '/pfop/';
return Qiniu_Client_CallWithForm($self, $url, $ReqParams);
}
示例4: Qiniu_Rio_Mkfile
function Qiniu_Rio_Mkfile($self, $host, $key, $fsize, $extra)
{
$entry = $extra->Bucket . ':' . $key;
$url = $host . '/rs-mkfile/' . Qiniu_Encode($entry) . '/fsize/' . $fsize;
if (!empty($extra->MimeType)) {
$url .= '/mimeType/' . Qiniu_Encode($extra->MimeType);
}
$ctxs = array();
foreach ($extra->Progresses as $prog) {
$ctxs[] = $prog['ctx'];
}
$body = implode(',', $ctxs);
return Qiniu_Client_CallWithForm($self, $url, $body, 'text/plain');
}
示例5: Qiniu_Rio_Mkfile
function Qiniu_Rio_Mkfile($self, $host, $key, $fsize, $extra)
{
$url = $host . '/mkfile/' . $fsize;
if ($key !== null) {
$url .= '/key/' . Qiniu_Encode($key);
}
if (!empty($extra->MimeType)) {
$url .= '/mimeType/' . Qiniu_Encode($extra->MimeType);
}
$ctxs = array();
foreach ($extra->Progresses as $prog) {
$ctxs[] = $prog['ctx'];
}
$body = implode(',', $ctxs);
return Qiniu_Client_CallWithForm($self, $url, $body, 'application/octet-stream');
}
示例6: Qiniu_RS_Batch
function Qiniu_RS_Batch($self, $ops)
{
global $QINIU_RS_HOST;
$url = $QINIU_RS_HOST . '/batch';
$params = 'op=' . implode('&op=', $ops);
return Qiniu_Client_CallWithForm($self, $url, $params);
}
示例7: urlencode
require_once "../../qiniu/http.php";
require_once "../../qiniu/auth_digest.php";
require_once "../../qiniu/utils.php";
$accessKey = "";
$secretKey = "";
$bucket = "";
$key = "";
$fops = "";
$notifyURL = "";
$force = 0;
$encodedBucket = urlencode($bucket);
$encodedKey = urlencode($key);
$encodedFops = urlencode($fops);
$encodedNotifyURL = urlencode($notifyURL);
$apiHost = "http://api.qiniu.com";
$apiPath = "/pfop/";
$requestBody = "bucket={$encodedBucket}&key={$encodedKey}&fops={$encodedFops}¬ifyURL={$encodedNotifyURL}";
if ($force !== 0) {
$requestBody .= "&force=1";
}
$mac = new Qiniu_Mac($accessKey, $secretKey);
$client = new Qiniu_MacHttpClient($mac);
list($ret, $err) = Qiniu_Client_CallWithForm($client, $apiHost . $apiPath, $requestBody);
if ($err !== null) {
echo "failed\n";
var_dump($err);
} else {
echo "success\n";
var_dump($ret);
}
示例8: Qiniu_Client_CallWithMultipartForm
function Qiniu_Client_CallWithMultipartForm($self, $url, $fields, $files)
{
list($contentType, $body) = Qiniu_Build_MultipartForm($fields, $files);
return Qiniu_Client_CallWithForm($self, $url, $body, $contentType);
}
示例9: getZipInfo
public static function getZipInfo($fileList = array(), $saveas = '')
{
require_once __DIR__ . '/../qiniu/http.php';
require_once __DIR__ . '/../qiniu/auth_digest.php';
require_once __DIR__ . '/../qiniu/utils.php';
$fops = 'mkzip/2';
$extraKey = null;
// var_export($fileList);
foreach ($fileList as $key => $value) {
if (preg_match('/^http:\\/\\//', $value)) {
if (is_int($key)) {
$fops .= '/url/' . Qiniu_Encode($value);
} else {
$fops .= '/url/' . Qiniu_Encode($value);
// $fops .= '/alias/'.Qiniu_Encode($key);
// var_export($key);
// var_export(Qiniu_Encode($key));
$fops .= '/alias/' . Qiniu_Encode($key);
}
if ($extraKey == null) {
$extraKey = $value;
}
}
}
if ($saveas == null) {
$saveas = md5($fops) . '.zip';
}
if ($saveas != null) {
$fops .= '|saveas/' . Qiniu_Encode(W2Config::$Qiniu_bucket . ':' . $saveas);
}
$persistentKey = 'mkzip.' . $saveas . '.pfop';
$saveFileInfo = W2Qiniu::getFileInfoFromQiniu($saveas);
if (is_array($saveFileInfo) && array_key_exists('fsize', $saveFileInfo)) {
return $saveFileInfo;
}
$persistentId = W2Qiniu::getKeyContent($persistentKey);
if (!is_null($persistentId)) {
return W2Qiniu::getPersistentInfo($persistentId);
}
if (strpos($extraKey, W2Config::$Qiniu_domain) != false) {
$extraKey = str_replace('http://' . W2Config::$Qiniu_domain . '/', '', $extraKey);
}
$notifyURL = "";
$force = 0;
$encodedBucket = urlencode(W2Config::$Qiniu_bucket);
$encodedKey = urlencode($extraKey);
$encodedFops = urlencode($fops);
$encodedNotifyURL = urlencode($notifyURL);
$apiHost = "http://api.qiniu.com";
$apiPath = "/pfop/";
$requestBody = "bucket={$encodedBucket}&key={$encodedKey}&fops={$encodedFops}¬ifyURL={$encodedNotifyURL}";
if ($force !== 0) {
$requestBody .= "&force=1";
}
$mac = new Qiniu_Mac(W2Config::$Qiniu_accessKey, W2Config::$Qiniu_secretKey);
$client = new Qiniu_MacHttpClient($mac);
list($ret, $err) = Qiniu_Client_CallWithForm($client, $apiHost . $apiPath, $requestBody);
if ($err !== null) {
var_dump($err);
} else {
if (is_array($ret) && array_key_exists('persistentId', $ret)) {
W2Qiniu::setKeyContent($persistentKey, $ret['persistentId']);
return W2Qiniu::getPersistentInfo($ret['persistentId']);
}
return $ret;
}
}