php sdk for 腾讯云万象图片服务
php composer.phar require tencentyun/php-sdk 调用请参考示例1
从github下载源码装入到您的程序中,并加载include.php 调用请参考示例2
修改Tencentyun/Conf.php内的appid等信息为您的配置
require('./vendor/autoload.php');
use Tencentyun\Image;
// 上传
$uploadRet = Image::upload('./154631959.jpg');
if (0 === $uploadRet['code']) {
$fileid = $uploadRet['data']['fileid'];
// 查询管理信息
$statRet = Image::stat($fileid);
var_dump($statRet);
$delRet = Image::del($fileid);
var_dump($delRet);
}
<?php
//require('./vendor/autoload.php');
require('./include.php');
use Tencentyun\Image;
use Tencentyun\Auth;
// 上传
$uploadRet = Image::upload('/tmp/amazon.jpg');
if (0 === $uploadRet['code']) {
$fileid = $uploadRet['data']['fileid'];
// 查询管理信息
$statRet = Image::stat($fileid);
var_dump($statRet);
// 复制
$copyRet = Image::copy($fileid);
var_dump($copyRet);
// 生成私密下载url
$downloadUrl = $copyRet['data']['downloadUrl'];
$sign = Auth::appSign($downloadUrl, 0);
$signedUrl = $downloadUrl . '?sign=' . $sign;
var_dump($signedUrl);
//生成新的上传签名
$expired = time() + 999;
$sign = Auth::appSign('http://web.image.myqcloud.com/photos/v1/200679/0/', $expired);
var_dump($sign);
$delRet = Image::del($fileid);
var_dump($delRet);
} else {
var_dump($uploadRet);
}