1、食谱TOP接口申请

1.1 定向申请地址

说明:目前只允许企业号进行申请;
http://my.open.taobao.com/common/applyIsv.htm?appTag=212&accessCode=E9780D2AC20DD170450FDBF555F67E3E

1.2 淘宝合作伙伴开发协议

image.png

1.3 填写开发者信息

image.png

1.4 创建食谱应用

image.png

1.5 申请TOP接口

image.png
image.png

2、SDK使用说明

2.1 选择需要的SDK版本进行构建

image.png

2.2 下载SDK并引入代码——JAVA演示

2.2.1 项目引入SDK包

(1)在项目resources目录下创建lib目录,将SDK包导入到该目录下
image.png

(2)pom中引入本地jar包

  1. <dependency>
  2. <groupId>ailib-iot</groupId>
  3. <artifactId>sdk-java-auto</artifactId>
  4. <version>1576072385423-20200612</version>
  5. <scope>system</scope>
  6. <systemPath>${project.basedir}/src/main/resources/lib/taobao-sdk-java-auto_1576072385423-20200612.jar</systemPath>
  7. </dependency>

2.3 食谱TOP接口调用——JAVA演示

2.3.1 插入或更新食谱测试

说明:返回结果是businessRecipeId 行业食谱id;

  1. /**
  2. * 插入或更新食谱测试
  3. */
  4. public static void insertOrUpdateRecipeTest() throws ApiException {
  5. DefaultTaobaoClient client = new DefaultTaobaoClient("http://gw.api.taobao.com/router/rest", "30281416",
  6. "4f9918cxxxxxxxxxxxxx6debcebaa");
  7. AlibabaAilabsIotBusinessRecipeInsertorupdateRequest request = new AlibabaAilabsIotBusinessRecipeInsertorupdateRequest();
  8. // 接口参数
  9. BusinessRecipeOpenParam businessRecipeOpenParam = new BusinessRecipeOpenParam();
  10. // 开放账号id
  11. businessRecipeOpenParam.setOpenAccountId("a2uDllguxxxxxxM3wkl+w==");
  12. // 食谱类型 0视频菜谱 1图文菜谱
  13. businessRecipeOpenParam.setRecipeType(1L);
  14. // 品类Id
  15. businessRecipeOpenParam.setDevTypeId(11L);
  16. // 食谱中文名称
  17. businessRecipeOpenParam.setRecipeNameCn("蜜瓜奶昔");
  18. // 食谱描述
  19. businessRecipeOpenParam.setDescription("蜜瓜富含膳食纤维,酸奶富含益生菌,两者均有助于肠道健康。");
  20. // 食谱图片
  21. ImageUrlParam recipeImage = new ImageUrlParam();
  22. recipeImage.setImg("http://www.xxx.com");
  23. businessRecipeOpenParam.setRecipeImage(recipeImage);
  24. // 食谱食材
  25. List<RecipeIngredientParam> recipeIngredientList = new ArrayList<>();
  26. RecipeIngredientParam recipeIngredientParam1 = new RecipeIngredientParam();
  27. recipeIngredientParam1.setName("蜜瓜");
  28. recipeIngredientParam1.setWeight("300g");
  29. recipeIngredientList.add(recipeIngredientParam1);
  30. RecipeIngredientParam recipeIngredientParam2 = new RecipeIngredientParam();
  31. recipeIngredientParam2.setName("酸奶");
  32. recipeIngredientParam2.setWeight("300g");
  33. recipeIngredientList.add(recipeIngredientParam2);
  34. businessRecipeOpenParam.setRecipeIngredientList(recipeIngredientList);
  35. request.setParamBusinessRecipeOpenParam(businessRecipeOpenParam);
  36. // 通用参数
  37. request.setTimestamp(System.currentTimeMillis());
  38. request.setTopApiVersion("2.0");
  39. request.setTopContentType("application/json");
  40. request.setTopHttpMethod("alibaba.ailabs.iot.business.recipe.insertorupdate");
  41. request.setTopResponseType("application/json");
  42. // 接口调用
  43. AlibabaAilabsIotBusinessRecipeInsertorupdateResponse response = client.execute(request);
  44. if (response.isSuccess()) {
  45. System.out.println(response.getBody());
  46. }
  47. }

2.3.2 插入或更新食谱步骤测试

说明:返回的是businessRecipeStepId 行业食谱步骤id;

  1. /**
  2. * 插入或更新食谱步骤测试
  3. */
  4. public static void insertOrUpdateRecipeStepTest() throws ApiException {
  5. DefaultTaobaoClient client = new DefaultTaobaoClient("http://gw.api.taobao.com/router/rest", "30281416",
  6. "4f9918cxxxxxxxxxxxxx6debcebaa");
  7. AlibabaAilabsIotBusinessRecipestepInsertorupdateRequest request = new AlibabaAilabsIotBusinessRecipestepInsertorupdateRequest();
  8. // 接口参数
  9. BusinessRecipeStepOpenParam businessRecipeStepOpenParam = new BusinessRecipeStepOpenParam();
  10. // 开放账号Id
  11. businessRecipeStepOpenParam.setOpenAccountId("a2uDllguxxxxxxM3wkl+w==");
  12. // 行业食谱id
  13. businessRecipeStepOpenParam.setBusinessRecipeId(6L);
  14. // 指令标识:0不支持指令,1支持指令
  15. businessRecipeStepOpenParam.setActionFlag(1L);
  16. // 食谱步骤中文名
  17. businessRecipeStepOpenParam.setRecipeStepNameCn("开始制作");
  18. // 食谱步骤描述
  19. businessRecipeStepOpenParam.setDescription("根据食谱称量口口蜜瓜块,然后放入研磨腔内,并加入3杯(300g)酸奶,选择“奶昔”功能键,点击“启动”即可");
  20. // 食谱步骤顺序号
  21. businessRecipeStepOpenParam.setSequence(1L);
  22. // 食谱步骤图片
  23. com.taobao.api.request.AlibabaAilabsIotBusinessRecipestepInsertorupdateRequest.ImageUrlParam imageUrl = new com.taobao.api.request.AlibabaAilabsIotBusinessRecipestepInsertorupdateRequest.ImageUrlParam();
  24. imageUrl.setImg("http://www.xxx.com");
  25. businessRecipeStepOpenParam.setImageUrl(imageUrl);
  26. // 食谱步骤时间
  27. businessRecipeStepOpenParam.setRecipeStepTime(180L);
  28. businessRecipeStepOpenParam.setTips("请检查食材是否都放入研磨腔内");
  29. // 步骤指令列表
  30. List<BusinessRecipeStepActionOpenParam> recipeStepActionList = new ArrayList<>();
  31. BusinessRecipeStepActionOpenParam businessRecipeStepActionOpenParam1 = new BusinessRecipeStepActionOpenParam();
  32. // 指令名
  33. businessRecipeStepActionOpenParam1.setActionName("runTime");
  34. // 指令值
  35. businessRecipeStepActionOpenParam1.setActionValue("180");
  36. // 指令顺序号
  37. businessRecipeStepActionOpenParam1.setSequence(1L);
  38. recipeStepActionList.add(businessRecipeStepActionOpenParam1);
  39. BusinessRecipeStepActionOpenParam businessRecipeStepActionOpenParam2 = new BusinessRecipeStepActionOpenParam();
  40. // 指令名
  41. businessRecipeStepActionOpenParam2.setActionName("recipeAction");
  42. // 指令值
  43. businessRecipeStepActionOpenParam2.setActionValue("2191000151000330031E50000530031E500005700000");
  44. // 指令顺序号
  45. businessRecipeStepActionOpenParam2.setSequence(2L);
  46. recipeStepActionList.add(businessRecipeStepActionOpenParam2);
  47. businessRecipeStepOpenParam.setRecipeStepActionList(recipeStepActionList);
  48. request.setParamBusinessRecipeStepOpenParam(businessRecipeStepOpenParam);
  49. // 通用参数
  50. request.setTimestamp(System.currentTimeMillis());
  51. request.setTopApiVersion("2.0");
  52. request.setTopContentType("application/json");
  53. request.setTopHttpMethod("alibaba.ailabs.iot.business.recipe.insertorupdate");
  54. request.setTopResponseType("application/json");
  55. // 接口调用
  56. AlibabaAilabsIotBusinessRecipestepInsertorupdateResponse response = client.execute(request);
  57. if (response.isSuccess()) {
  58. System.out.println(response.getBody());
  59. }
  60. }

2.3.3 获取食谱分页数据

说明:返回结果是用户维度的食谱概要数据;

  1. /**
  2. * 获取食谱分页数据
  3. *
  4. * @throws ApiException
  5. */
  6. public static void getRecipePageTest() throws ApiException {
  7. DefaultTaobaoClient client = new DefaultTaobaoClient("http://gw.api.taobao.com/router/rest", "30281416",
  8. "4f9918cxxxxxxxxxxxxx6debcebaa");
  9. AlibabaAilabsIotBusinessRecipeGetpageRequest request = new AlibabaAilabsIotBusinessRecipeGetpageRequest();
  10. // 开放账号id
  11. request.setOpenAccountId("a2uDllguxxxxxxM3wkl+w==");
  12. // 分页页数
  13. request.setPageNum(1L);
  14. // 分页大小
  15. request.setPageSize(10L);
  16. // 通用参数
  17. request.setTimestamp(System.currentTimeMillis());
  18. request.setTopApiVersion("2.0");
  19. request.setTopContentType("application/json");
  20. request.setTopHttpMethod("alibaba.ailabs.iot.business.recipe.getdetail");
  21. request.setTopResponseType("application/json");
  22. // 接口调用
  23. AlibabaAilabsIotBusinessRecipeGetpageResponse response = client.execute(request);
  24. if (response.isSuccess()) {
  25. System.out.println(response.getBody());
  26. }
  27. }

2.3.4 获取食谱详情数据

  1. /**
  2. * 获取食谱详情测试
  3. *
  4. * @throws ApiException
  5. */
  6. public static void getRecipeDetailTest() throws ApiException {
  7. DefaultTaobaoClient client = new DefaultTaobaoClient("http://gw.api.taobao.com/router/rest", "30281416",
  8. "4f9918cxxxxxxxxxxxxx6debcebaa");
  9. AlibabaAilabsIotBusinessRecipeGetdetailRequest request = new AlibabaAilabsIotBusinessRecipeGetdetailRequest();
  10. // 开放账号id
  11. request.setOpenAccountId("a2uDllguxxxxxxM3wkl+w==");
  12. // 食谱id
  13. request.setBusinessRecipeId(1L);
  14. // 通用参数
  15. request.setTimestamp(System.currentTimeMillis());
  16. request.setTopApiVersion("2.0");
  17. request.setTopContentType("application/json");
  18. request.setTopHttpMethod("alibaba.ailabs.iot.business.recipe.getdetail");
  19. request.setTopResponseType("application/json");
  20. // 接口调用
  21. AlibabaAilabsIotBusinessRecipeGetdetailResponse response = client.execute(request);
  22. if (response.isSuccess()) {
  23. System.out.println(response.getBody());
  24. }
  25. }

3、补充文档

3.1 TOP接口操作文档

https://open.taobao.com/doc.htm?docId=101617&docType=1

3.2 OpenAccountId问题

请提供IOT开放平台账号邮箱给小二,由小二生成给到ISV;

3.3 厨电品类文档

https://www.aligenie.com/doc/357554/hiku59

3.4 食谱标签文档

https://www.aligenie.com/doc/357554/xum3re