跨境电商语言工具调用方式
请求体为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"
}