TaobaoClient client = new DefaultTaobaoClient(url, appkey, secret);
AlitripFlightServiceUploadRequest req = new AlitripFlightServiceUploadRequest();
req.setFileContent(new FileItem("/tmp/file.txt"));
AlitripFlightServiceUploadRequest.UploadAttachmentReq obj1 = new AlitripFlightServiceUploadRequest.UploadAttachmentReq();
obj1.setOrderId(974032987432L);
obj1.setExternalAgentName("飞猪自营");
req.setUploadAttachmentReq(obj1);
AlitripFlightServiceUploadResponse rsp = client.execute(req, sessionKey);
System.out.println(rsp.getBody());
ITopClient client = new DefaultTopClient(url, appkey, secret);
AlitripFlightServiceUploadRequest req = new AlitripFlightServiceUploadRequest();
req.FileContent = new FileItem("/tmp/file.txt");
AlitripFlightServiceUploadRequest.UploadAttachmentReqDomain obj1 = new AlitripFlightServiceUploadRequest.UploadAttachmentReqDomain();
obj1.OrderId = 974032987432L;
obj1.ExternalAgentName = "飞猪自营";
req.UploadAttachmentReq_ = obj1;
AlitripFlightServiceUploadResponse rsp = client.Execute(req, sessionKey);
Console.WriteLine(rsp.Body);
$c = new TopClient;
$c->appkey = $appkey;
$c->secretKey = $secret;
$req = new AlitripFlightServiceUploadRequest;
//附件上传的机制参见PHP CURL文档,在文件路径前加@符号即可
$req->setFileContent(@fileLocation);
$upload_attachment_req = new UploadAttachmentReq;
$upload_attachment_req->order_id="974032987432";
$upload_attachment_req->external_agent_name="飞猪自营";
$req->setUploadAttachmentReq(json_encode($upload_attachment_req));
$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=alitrip.flight.service.upload' \
-F 'partner_id=apidoc' \
-F 'session=6d3b49f7-71f0-4f35-bbcc-39a744013608' \
-F 'sign=8FFED3CCD243D09746D8318899FA92BE' \
-F 'sign_method=hmac' \
-F 'timestamp=2025-01-30+12%3A51%3A59' \
-F 'v=2.0' \
-F 'upload_attachment_req=null' \
-F 'file_content=@/tmp/file.txt'
# -*- coding: utf-8 -*-
import top.api
req=top.api.AlitripFlightServiceUploadRequest(url,port)
req.set_app_info(top.appinfo(appkey,secret))
req.file_content=top.api.FileItem('abc.jpg',open('abc.jpg','rb'))
req.upload_attachment_req="数据结构示例JSON格式"
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,"alitrip.flight.service.upload");
add_file_param(pRequest,"file_content","文件内容");
add_param(pRequest,"upload_attachment_req","数据结构JSON示例");
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('alitrip.flight.service.upload', {
'file_content':'文件内容',
'upload_attachment_req':'数据结构JSON示例'
}, function(error, response) {
if (!error) console.log(response);
else console.log(error);
})