請求體為json結構字符串,服務返回也為json字符串,具體要求參考各API文檔,示例請求(java):
服務地址
地域 | 接入地址 |
杭州 | mt.cn-hangzhou.aliyuncs.com |
HTTP接口地址
http://mt.cn-hangzhou.aliyuncs.com/api/resource
正常返回
請求正常結果,為JSON字符串。
錯誤返回:{"errorCode":"errorCode","errorMsg":"錯誤消息"}
字符編碼:請求及返回結果都使用 UTF-8 字符集進行編碼。
請求體與結果返回
public static void main(String[] args) {
String serviceURL = "http://mt.cn-hangzhou.aliyuncs.com/api/resource";
String accessKeyId = "";// 使用您的阿里云訪問密鑰 AccessKeyId
String accessKeySecret = ""; // 使用您的阿里云訪問密鑰
String postBody = "{\n" +
" \"ApiName\": \"imageTranslate\",\n" +
" \"Params\": {\n" +
" \"extra\": \" {\\\"without_text\\\":\\\"true\\\"}\",\n" +
" \"sourceLanguage\": \"zh\",\n" +
" \"targetLanguage\": \"en\",\n" +
" \"url\": \"https://img.alicdn.com/imgextra/i4/388322682/O1CN011VgOhz82ye0dlh0_!!388322682.jpg\"\n" +
" }\n" +
"}";
// Sender代碼請參考幫助文檔“簽名方法”
String result = Sender.sendPost(serviceURL, postBody, accessKeyId, accessKeySecret);
System.out.println(result);
}
HTTP接口參數說明
ApiName | imageTranslate:商品圖片智能翻譯 imageDiagnose:圖片診斷 titleIntelligence:標題智能生成 titleGenerate:標題優化 titleDiagnose:標題診斷 |
Params | 對應各個API接口具體的參數,如下 |
商品圖片智能翻譯demo postBody示例
{
"ApiName": "imageTranslate",
"Params": {
"extra": " {\"without_text\":\"true\"}",
"sourceLanguage": "zh",
"targetLanguage": "en",
"url": "https://img.alicdn.com/imgextra/i4/388322682/O1CN011VgOhz82ye0dlh0_!!388322682.jpg"
}
}
圖片診斷demo postBody示例
{
"ApiName": "imageDiagnose",
"Params": {
"extra": " {\"product_id\":\"12121\"}",
"url": "https://img.alicdn.com/imgextra/i4/388322682/O1CN011VgOhz82ye0dlh0_!!388322682.jpg"
}
}
標題智能生成demo postBody示例
{
"ApiName": "titleIntelligence",
"Params": {
"catLevel2Id": 111,
"catLevel3Id": 3333,
"extra": " {\"product_id\":\"12121\"}",
"keywords": "hello,apple",
"platform": "ae"
}
}
標題優化demo postBody示例
{
"ApiName": "titleGenerate",
"Params": {
"attributes": {
"2": "None",
"10": "Plastic"
},
"categoryId": 111,
"extra": " {\"product_id\":\"12121\"}",
"hotWords": "watch,apple",
"language": "en",
"platform": "ae",
"title": "apple watch is good"
}
}
標題診斷demo postBody示例
{
"ApiName": "titleDiagnose",
"Params": {
"categoryId": 111,
"extra": " {\"product_id\":\"12121\"}",
"language": "en",
"platform": "ae",
"title": "apple watch is good"
}
文檔內容是否對您有幫助?