全部产品
云市场

媒资分类

更新时间:2018-12-30 17:41:58

初始化客户端

使用前请先初始化客户端,参考 initVodClient 接口。

创建分类

接口参数和返回字段请参考 AddCategory

  1. function addCategory($client, $cateName, $parentId=-1) {
  2. $request = new vod\AddCategoryRequest();
  3. $request->setCateName($cateName);
  4. $request->setParentId($parentId);
  5. $request->setAcceptFormat('JSON');
  6. return $client->getAcsResponse($request);
  7. }
  8. try {
  9. $client = initVodClient('<AccessKeyId>', '<AccessKeySecret>');
  10. $addRes = addCategory($client, 'Category Name');
  11. var_dump($addRes);
  12. } catch (Exception $e) {
  13. print $e->getMessage()."\n";
  14. }

修改分类

接口参数和返回字段请参考 UpdateCategory

  1. function updateCategory($client, $cateId, $cateName) {
  2. $request = new vod\UpdateCategoryRequest();
  3. $request->setCateId($cateId);
  4. $request->setCateName($cateName); // 分类名称
  5. $request->setAcceptFormat('JSON');
  6. return $client->getAcsResponse($request);
  7. }
  8. try {
  9. $client = initVodClient('<AccessKeyId>', '<AccessKeySecret>');
  10. $updateRes = updateCategory($client, '<Category ID>', 'New Category Name');
  11. var_dump($updateRes);
  12. } catch (Exception $e) {
  13. print $e->getMessage()."\n";
  14. }

删除分类

接口参数和返回字段请参考 DeleteCategory

  1. // 删除视频分类,同时会删除其下级分类(包括二级分类和三级分类),请慎重操作
  2. function deleteCategory($client, $cateId) {
  3. $request = new vod\DeleteCategoryRequest();
  4. $request->setCateId($cateId);
  5. $request->setAcceptFormat('JSON');
  6. return $client->getAcsResponse($request);
  7. }
  8. try {
  9. $client = initVodClient('<AccessKeyId>', '<AccessKeySecret>');
  10. $delRes = deleteCategory($client, '<Category ID>');
  11. var_dump($delRes);
  12. } catch (Exception $e) {
  13. print $e->getMessage()."\n";
  14. }

查询分类及其子分类

接口参数和返回字段请参考 GetCategories

  1. // 获取指定的分类信息,及其子分类(即下一级分类)的列表
  2. function getCategories($client, $cateId=-1, $pageNo=1, $pageSize=10) {
  3. $request = new vod\GetCategoriesRequest();
  4. $request->setCateId($cateId); // 分类ID,默认为根节点分类ID即-1
  5. $request->setPageNo($pageNo);
  6. $request->setPageSize($pageSize);
  7. $request->setAcceptFormat('JSON');
  8. return $client->getAcsResponse($request);
  9. }
  10. try {
  11. $client = initVodClient('<AccessKeyId>', '<AccessKeySecret>');
  12. $getRes = getCategories($client, '<Category Id>');
  13. var_dump($getRes);
  14. } catch (Exception $e) {
  15. print $e->getMessage()."\n";
  16. }