本文整理汇总了PHP中Qiniu_SetKeys函数的典型用法代码示例。如果您正苦于以下问题:PHP Qiniu_SetKeys函数的具体用法?PHP Qiniu_SetKeys怎么用?PHP Qiniu_SetKeys使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了Qiniu_SetKeys函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: initSDK
public static function initSDK($accesskey, $sercetkey)
{
// 调用 SDK 设置密钥
require_once 'sdk/io.php';
require_once 'sdk/rs.php';
Qiniu_SetKeys($accesskey, $sercetkey);
}
示例2: initKeys
function initKeys()
{
global $accessKey, $secretKey;
if (!empty($accessKey) && !empty($secretKey)) {
Qiniu_SetKeys($accessKey, $secretKey);
}
}
示例3: deleteResByTopicIDArray
private function deleteResByTopicIDArray($badTopicList)
{
if (empty($badTopicList)) {
return true;
}
require_once dirname(dirname(dirname(__FILE__))) . DIRECTORY_SEPARATOR . 'application' . DIRECTORY_SEPARATOR . 'third_party' . DIRECTORY_SEPARATOR . 'qiniu' . DIRECTORY_SEPARATOR . 'rs.php';
if (!empty($badTopicList)) {
foreach ($badTopicList as $key => $topic) {
$resUrl = $topic['resUrl'];
if (!empty($resUrl)) {
$qn = getQNFromUrl($resUrl);
Qiniu_SetKeys(JY_QN_accessKey, JY_QN_secretKey);
$client = new Qiniu_MacHttpClient(null);
$err = Qiniu_RS_Move($client, $qn['bucket'], $qn['key'], JY_QN_bucket_recycle, $qn['key']);
if ($err !== null && $err->Code != 612) {
$this->topic->insertBadTopic($topic['id'], $resUrl, $err->Code);
return false;
} else {
return true;
}
}
}
}
return true;
}
示例4: save
public function save($url, $config)
{
set_time_limit(0);
if (empty($url)) {
return '';
}
$ext = strrchr($url, ".");
if ($ext != ".jpeg" && $ext != ".gif" && $ext != ".jpg" && $ext != ".png") {
return "";
}
$filename = random(30) . $ext;
if (!$this->check_remote_file_exists($url)) {
return "";
}
$contents = @file_get_contents($url);
$storename = $filename;
$bu = $config['bucket'] . ":" . $storename;
$accessKey = $config['access_key'];
$secretKey = $config['secret_key'];
Qiniu_SetKeys($accessKey, $secretKey);
$putPolicy = new Qiniu_RS_PutPolicy($bu);
$upToken = $putPolicy->Token(null);
$putExtra = new Qiniu_PutExtra();
$putExtra->Crc32 = 1;
list($ret, $err) = Qiniu_Put($upToken, $storename, $contents, $putExtra);
if (!empty($err)) {
return "";
}
return 'http://' . trim($config['url']) . "/" . $ret['key'];
}
示例5: upload_qiniu
public function upload_qiniu($file = "", $name = "")
{
$path = $_SERVER['DOCUMENT_ROOT'];
require_once $path . "/app/libraries/qiniu/rs.php";
require_once $path . "/app/libraries/qiniu/io.php";
$bucket = "meilimei";
$local_file = "upload/" . $name;
$key = $local_file;
$accessKey = 'tjtiZoMyJa9ggnNisrdocCCGvTlNLFvYxGMMQ6LF';
$secretKey = '6zQXHont_jN-QFznn96H4oKA7IUqjibPeC-Yto62';
Qiniu_SetKeys($accessKey, $secretKey);
$putPolicy = new Qiniu_RS_PutPolicy($bucket);
$upToken = $putPolicy->Token(null);
if (move_uploaded_file($file, $local_file)) {
$upload_file = $path . "/upload/" . $name;
$putExtra = new Qiniu_PutExtra();
$putExtra->Crc32 = 1;
list($ret, $err) = Qiniu_PutFile($upToken, $key, $upload_file, $putExtra);
if ($err !== null) {
return false;
} else {
//var_dump($ret);
return $ret;
}
} else {
return false;
// echo "move_uploaded错误!";
// die;
}
return false;
}
示例6: __construct
public function __construct($accessKey, $secretKey, $bucket)
{
$this->bucket = $bucket;
require_once "qiniu/rs.php";
Qiniu_SetKeys($accessKey, $secretKey);
$putPolicy = new Qiniu_RS_PutPolicy($bucket);
$this->putPolicy = $putPolicy;
}
示例7: upload
public function upload($key, $source)
{
Qiniu_SetKeys($this->accessKey, $this->secretKey);
$putPolicy = new Qiniu_RS_PutPolicy($this->bucket);
$upToken = $putPolicy->Token(null);
$putExtra = new Qiniu_PutExtra();
$putExtra->Crc32 = 1;
return Qiniu_PutFile($upToken, $key, $source, $putExtra);
}
示例8: __construct
public function __construct(ContainerInterface $container, $accessKey, $secretKey, $bucket, $domain)
{
$this->container = $container;
$this->accessKey = $accessKey;
$this->secretKey = $secretKey;
$this->bucket = $bucket;
$this->domain = $domain;
Qiniu_SetKeys($this->accessKey, $this->secretKey);
$this->client = new \Qiniu_MacHttpClient(null);
}
示例9: getToken
/**
* Get qiniu token
* @param null $key
* @return string qiniu token
*/
public function getToken($key = null)
{
Qiniu_SetKeys($this->accessKey, $this->secretKey);
$scope = $this->bucket;
if (!empty($key)) {
// allowed to overwrite the file
$scope .= ':' . $key;
}
$putPolicy = new \Qiniu_RS_PutPolicy($scope);
$upToken = $putPolicy->Token(null);
return $upToken;
}
示例10: getSign
/**
* 设置路径
* @param $key
* @param null $returnUrl
* @param null $returnBody
* @return string
*/
public function getSign($preKey = '', $returnUrl = null, $returnBody = null)
{
Qiniu_SetKeys(Yii::app()->params['QINIU_ACCESS_KEY'], Yii::app()->params['QINIU_SECRET_KEY']);
$putPolicy = new Qiniu_RS_PutPolicy(Yii::app()->params['QINIU_BUCKET']);
$putPolicy->Expires = 60 * 30;
$putPolicy->SaveKey = $preKey . '$(etag)';
$putPolicy->MimeLimit = 'image/*';
if ($returnUrl !== null) {
$putPolicy->CallbackUrl = $returnUrl;
}
if ($returnBody !== null) {
$putPolicy->CallbackBody = urldecode(http_build_query($returnBody));
}
$upToken = $putPolicy->Token(null);
return $upToken;
}
示例11: qiniu
function qiniu()
{
echo 'qiniu';
$bucket = "xappqiniu";
$key = "apartment_1.jpg";
$accessKey = 'f9zK0PZeWtFNGY5lxrXeOM6MphG2xxNYBuXv6fGn';
$secretKey = 'PFSvanHSINAYXoW_-PBTUUNpkA7IU-w7q3pQ1JNj';
Qiniu_SetKeys($accessKey, $secretKey);
$client = new Qiniu_MacHttpClient(null);
list($ret, $err) = Qiniu_RS_Stat($client, $bucket, $key);
echo "Qiniu_RS_Stat result: \n";
if ($err !== null) {
var_dump($err);
} else {
var_dump($ret);
}
}
示例12: __construct
function __construct($params)
{
/** 实例化*/
$this->ci =& get_instance();
require_once "qiniu/io.php";
require_once "qiniu/rs.php";
//
$this->accessKey = $params['accesskey'];
$this->secretKey = $params['secretkey'];
$this->bucket = $params['bucket'];
$this->file_domain = $params['file_domain'];
$key = 'test.png';
Qiniu_SetKeys($this->accessKey, $this->secretKey);
$putPolicy = new Qiniu_RS_PutPolicy($this->bucket);
$this->upToken = $putPolicy->Token(null);
$this->putExtra = new Qiniu_PutExtra();
$this->putExtra->Crc32 = 1;
}
示例13: doMobileUpload
public function doMobileUpload()
{
require_once "qiniu.config.php";
global $_GPC;
$serverId = $_GPC['serverId'];
//获取音频链接
$fileName = substr($serverId, -10) . '.amr';
$url = 'http://file.api.weixin.qq.com/cgi-bin/media/get?access_token=' . $this->jssdk->getAccessToken() . '&media_id=' . $serverId;
$body = $this->jssdk->HttpGet($url);
// 上传至七牛
Qiniu_SetKeys($qiniu['accessKey'], $qiniu['secretKey']);
$putPolicy = new Qiniu_RS_PutPolicy($qiniu['bucket']);
$upToken = $putPolicy->Token(null);
list($ret, $err) = Qiniu_Put($upToken, $fileName, $body, null);
if ($err !== null) {
var_dump($err);
} else {
// var_dump($ret);
echo 'http://' . $qiniu['domainName'] . '/' . $fileName;
}
}
示例14: getImageView
public function getImageView($mode = 0, $width = '', $height = '', $format = '', $interlace = '')
{
require_once LIBPATH . 'Qiniu/rs.php';
require_once LIBPATH . 'Qiniu/fop.php';
$domain = $this->bucket . '.qiniudn.com';
Qiniu_SetKeys($this->accessKey, $this->secretKey);
//生成baseUrl
$baseUrl = Qiniu_RS_MakeBaseUrl($domain, $filename);
//生成fopUrl
$imgView = new Qiniu_ImageView();
$imgView->Mode = $mode;
$imgView->Width = $width;
$imgView->Height = $height;
$imgView->Format = $format;
$imgView->Interlace = $interlace;
$imgViewUrl = $imgView->MakeRequest();
//对fopUrl 进行签名,生成privateUrl。 公有bucket 此步可以省去。
// $getPolicy = new Qiniu_RS_GetPolicy();
// return $getPolicy->MakeRequest($imgViewUrl, null);
return $imgViewUrl;
}
示例15: uploadFile
/**
* 文件上传
* @param string $filePath 待上传文件的绝对路径
* @return string 上传成功后的URL,失败时返回空
*/
public function uploadFile($filePath)
{
$fileUrl = '';
if (!file_exists($filePath)) {
return $fileUrl;
}
$config = $this->config;
$fileName = date('YmdHis_', $_SERVER['REQUEST_TIME']) . md5(PhalApi_Tool::createRandStr(8) . microtime(true));
Qiniu_SetKeys($config['accessKey'], $config['secretKey']);
$putPolicy = new Qiniu_RS_PutPolicy($config['space_bucket']);
$upToken = $putPolicy->Token(null);
$putExtra = new Qiniu_PutExtra();
$putExtra->Crc32 = 1;
list($ret, $err) = Qiniu_PutFile($upToken, $fileName, $filePath, $putExtra);
if ($err !== null) {
DI()->logger->debug('failed to upload file to qiniu', array('Err' => $err->Err, 'Reqid' => $err->Reqid, 'Details' => $err->Details, 'Code' => $err->Code));
} else {
$fileUrl = $config['space_host'] . '/' . $fileName;
DI()->logger->debug('succeed to upload file to qiniu', $ret);
}
return $fileUrl;
}