|
| 1 | +<?php |
| 2 | + |
| 3 | +require dirname(__FILE__) . '/../vendor/autoload.php'; |
| 4 | + |
| 5 | +$secretId = "SECRETID"; //替换为用户的 secretId,请登录访问管理控制台进行查看和管理,https://console.cloud.tencent.com/cam/capi |
| 6 | +$secretKey = "SECRETKEY"; //替换为用户的 secretKey,请登录访问管理控制台进行查看和管理,https://console.cloud.tencent.com/cam/capi |
| 7 | +$region = "ap-beijing"; //替换为用户的 region,已创建桶归属的region可以在控制台查看,https://console.cloud.tencent.com/cos5/bucket |
| 8 | +$cosClient = new Qcloud\Cos\Client( |
| 9 | + array( |
| 10 | + 'region' => $region, |
| 11 | + 'schema' => 'https', //协议头部,默认为http |
| 12 | + 'credentials'=> array( |
| 13 | + 'secretId' => $secretId , |
| 14 | + 'secretKey' => $secretKey))); |
| 15 | +try { |
| 16 | + // 提交图片处理任务 https://cloud.tencent.com/document/product/436/67194 |
| 17 | + // start --------------- 使用模版 ----------------- // |
| 18 | + $result = $cosClient->createMediaPicProcessJobs(array( |
| 19 | + 'Bucket' => 'examplebucket-125000000', //存储桶名称,由BucketName-Appid 组成,可以在COS控制台查看 https://console.cloud.tencent.com/cos5/bucket |
| 20 | + 'Tag' => 'PicProcess', |
| 21 | + 'QueueId' => 'pcf4d6d9e5e734asd0as8d09as8d09a8d0', |
| 22 | + 'Input' => array( |
| 23 | + 'Object' => 'test01.png' |
| 24 | + ), |
| 25 | + 'Operation' => array( |
| 26 | + 'TemplateId' => 't1648745f76c354e8ad8a09sd890ad80a8d', |
| 27 | + 'Output' => array( |
| 28 | + 'Region' => $region, |
| 29 | + 'Bucket' => 'examplebucket-125000000', //存储桶名称,由BucketName-Appid 组成,可以在COS控制台查看 https://console.cloud.tencent.com/cos5/bucket |
| 30 | + 'Object' => 'picprocess.jpg', |
| 31 | + ), |
| 32 | + ), |
| 33 | + 'CallBack' => '', |
| 34 | + )); |
| 35 | + // 请求成功 |
| 36 | + print_r($result); |
| 37 | + // end --------------- 使用模版 ----------------- // |
| 38 | + |
| 39 | + |
| 40 | + // start --------------- 自定义参数 ----------------- // |
| 41 | + $result = $cosClient->createMediaPicProcessJobs(array( |
| 42 | + 'Bucket' => 'examplebucket-125000000', //存储桶名称,由BucketName-Appid 组成,可以在COS控制台查看 https://console.cloud.tencent.com/cos5/bucket |
| 43 | + 'Tag' => 'PicProcess', |
| 44 | + 'QueueId' => 'pcf4d6d9e5e734asd0as8d09as8d09a8d0', |
| 45 | + 'Input' => array( |
| 46 | + 'Object' => 'test01.png' |
| 47 | + ), |
| 48 | + 'Operation' => array( |
| 49 | + 'PicProcess' => array( |
| 50 | + 'IsPicInfo' => '', |
| 51 | + 'ProcessRule' => '', |
| 52 | + ), |
| 53 | + 'Output' => array( |
| 54 | + 'Region' => $region, |
| 55 | + 'Bucket' => 'examplebucket-125000000', //存储桶名称,由BucketName-Appid 组成,可以在COS控制台查看 https://console.cloud.tencent.com/cos5/bucket |
| 56 | + 'Object' => 'picprocess.jpg', |
| 57 | + ), |
| 58 | + ), |
| 59 | + 'CallBack' => '', |
| 60 | + )); |
| 61 | + // 请求成功 |
| 62 | + print_r($result); |
| 63 | + // end --------------- 自定义参数 ----------------- // |
| 64 | +} catch (\Exception $e) { |
| 65 | + // 请求失败 |
| 66 | + echo($e); |
| 67 | +} |
0 commit comments