TaobaoClient client = new DefaultTaobaoClient(url, appkey, secret);
AlitripItFareBatchaddRequest req = new AlitripItFareBatchaddRequest();
req.setAddType(1L);
req.setBytes(new FileItem("/tmp/file.txt"));
req.setDataType(1L);
req.setExtendAttributes("{}");
AlitripItFareBatchaddResponse rsp = client.execute(req, sessionKey);
System.out.println(rsp.getBody());
ITopClient client = new DefaultTopClient(url, appkey, secret);
AlitripItFareBatchaddRequest req = new AlitripItFareBatchaddRequest();
req.AddType = 1L;
req.Bytes = new FileItem("/tmp/file.txt");
req.DataType = 1L;
req.ExtendAttributes = "{}";
AlitripItFareBatchaddResponse rsp = client.Execute(req, sessionKey);
Console.WriteLine(rsp.Body);
$c = new TopClient;
$c->appkey = $appkey;
$c->secretKey = $secret;
$req = new AlitripItFareBatchaddRequest;
$req->setAddType("1");
//附件上传的机制参见PHP CURL文档,在文件路径前加@符号即可
$req->setBytes(@fileLocation);
$req->setDataType("1");
$req->setExtendAttributes("{}");
$resp = $c->execute($req, $sessionKey);
curl -X POST 'http://gw.api.taobao.com/router/rest' \
-H 'Content-Type:multipart/form-data;charset=utf-8' \
-F 'app_key=12129701' \
-F 'format=json' \
-F 'method=taobao.alitrip.it.fare.batchadd' \
-F 'partner_id=apidoc' \
-F 'session=e2920b30-fa76-4338-aaca-4aca90b934be' \
-F 'sign=59C794FC78E9B7F6CA6962009F6E7632' \
-F 'sign_method=hmac' \
-F 'timestamp=2024-11-23+16%3A23%3A09' \
-F 'v=2.0' \
-F 'addType=1' \
-F 'dataType=1' \
-F 'extendAttributes=%7B%7D' \
-F 'bytes=@/tmp/file.txt'
# -*- coding: utf-8 -*-
import top.api
req=top.api.AlitripItFareBatchaddRequest(url,port)
req.set_app_info(top.appinfo(appkey,secret))
req.addType=1
req.bytes=top.api.FileItem('abc.jpg',open('abc.jpg','rb'))
req.dataType=1
req.extendAttributes="{}"
try:
resp= req.getResponse(sessionkey)
print(resp)
except Exception,e:
print(e)
pTopRequest pRequest = alloc_top_request();
pTopResponse pResponse = NULL;
pTaobaoClient pClient = alloc_taobao_client(url, appkey, appsecret);
set_api_name(pRequest,"taobao.alitrip.it.fare.batchadd");
add_param(pRequest,"addType","1");
add_file_param(pRequest,"bytes","文件内容");
add_param(pRequest,"dataType","1");
add_param(pRequest,"extendAttributes","{}");
pResponse = top_execute(pClient,pRequest,sessionKey);
printf("ret code:%d\n",pResponse->code);
if(pResponse->code == 0){
pTopResponseIterator ite = init_response_iterator(pResponse);
pResultItem pResultItem = alloc_result_item();
while(parseNext(ite, pResultItem) == 0){
printf("%s:%s\n",pResultItem->key,pResultItem->value);
}
destroy_response_iterator(ite);
destroy_result_item(pResultItem);
}
destroy_top_request(pRequest);
destroy_top_response(pResponse);
destroy_taobao_client(pClient);
TopClient = require('./topClient').TopClient;
var client = new TopClient({
'appkey': 'appkey',
'appsecret': 'secret',
'REST_URL': 'http://gw.api.taobao.com/router/rest'
});
client.execute('taobao.alitrip.it.fare.batchadd', {
'addType':'1',
'bytes':'文件内容',
'dataType':'1',
'extendAttributes':'{}'
}, function(error, response) {
if (!error) console.log(response);
else console.log(error);
})