TaobaoClient client = new DefaultTaobaoClient(url, appkey, secret);
XhotelRoomAddRequest req = new XhotelRoomAddRequest();
req.setHid(100000L);
req.setRid(100000L);
req.setTitle("aaa");
req.setGuide("aaa");
req.setDesc("bbb");
req.setPic(new FileItem("/tmp/file.txt"));
req.setHasReceipt(true);
req.setReceiptType("A");
req.setReceiptOtherTypeDesc("aaa");
req.setReceiptInfo("bbb");
req.setInventory("[{\"date\":2011-01-28,\"quota\":10},{\"date\":2011-01-29,\"quota\":10}]");
req.setVendor("chinaonline");
req.setOutRid("12345321");
req.setRoomSwitchCal("[{\"date\":\"yyyy-MM-dd\",\"room_status\":2},{\"date\":\"yyyy-MM-dd\",\"room_status\":1}]");
XhotelRoomAddResponse rsp = client.execute(req, sessionKey);
System.out.println(rsp.getBody());
ITopClient client = new DefaultTopClient(url, appkey, secret);
XhotelRoomAddRequest req = new XhotelRoomAddRequest();
req.Hid = 100000L;
req.Rid = 100000L;
req.Title = "aaa";
req.Guide = "aaa";
req.Desc = "bbb";
req.Pic = new FileItem("/tmp/file.txt");
req.HasReceipt = true;
req.ReceiptType = "A";
req.ReceiptOtherTypeDesc = "aaa";
req.ReceiptInfo = "bbb";
req.Inventory = "[{\"date\":2011-01-28,\"quota\":10},{\"date\":2011-01-29,\"quota\":10}]";
req.Vendor = "chinaonline";
req.OutRid = "12345321";
req.RoomSwitchCal = "[{\"date\":\"yyyy-MM-dd\",\"room_status\":2},{\"date\":\"yyyy-MM-dd\",\"room_status\":1}]";
XhotelRoomAddResponse rsp = client.Execute(req, sessionKey);
Console.WriteLine(rsp.Body);
$c = new TopClient;
$c->appkey = $appkey;
$c->secretKey = $secret;
$req = new XhotelRoomAddRequest;
$req->setHid("100000");
$req->setRid("100000");
$req->setTitle("aaa");
$req->setGuide("aaa");
$req->setDesc("bbb");
//附件上传的机制参见PHP CURL文档,在文件路径前加@符号即可
$req->setPic(@fileLocation);
$req->setHasReceipt("true");
$req->setReceiptType("A");
$req->setReceiptOtherTypeDesc("aaa");
$req->setReceiptInfo("bbb");
$req->setInventory("[{\"date\":2011-01-28,\"quota\":10},{\"date\":2011-01-29,\"quota\":10}]");
$req->setVendor("chinaonline");
$req->setOutRid("12345321");
$req->setRoomSwitchCal("[{\"date\":\"yyyy-MM-dd\",\"room_status\":2},{\"date\":\"yyyy-MM-dd\",\"room_status\":1}]");
$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.xhotel.room.add' \
-F 'partner_id=apidoc' \
-F 'session=3c576e36-2769-4f0a-8d4f-2736844255e8' \
-F 'sign=66F61DB6BE28FFAF8281505C5E3249C3' \
-F 'sign_method=hmac' \
-F 'timestamp=2024-12-27+09%3A13%3A14' \
-F 'v=2.0' \
-F 'desc=bbb' \
-F 'guide=aaa' \
-F 'has_receipt=true' \
-F 'hid=100000' \
-F 'inventory=%7B%22date%22%3A2011-01-28%2C%22quota%22%3A10%7D%2C%7B%22date%22%3A2011-01-29%2C%22quota%22%3A10%7D' \
-F 'out_rid=12345321' \
-F 'receipt_info=bbb' \
-F 'receipt_other_type_desc=aaa' \
-F 'receipt_type=A' \
-F 'rid=100000' \
-F 'room_switch_cal=%7B%22date%22%3A%22yyyy-MM-dd%22%2C%22room_status%22%3A2%7D%2C%7B%22date%22%3A%22yyyy-MM-dd%22%2C%22room_status%22%3A1%7D' \
-F 'title=aaa' \
-F 'vendor=chinaonline' \
-F 'pic=@/tmp/file.txt'
# -*- coding: utf-8 -*-
import top.api
req=top.api.XhotelRoomAddRequest(url,port)
req.set_app_info(top.appinfo(appkey,secret))
req.hid=100000
req.rid=100000
req.title="aaa"
req.guide="aaa"
req.desc="bbb"
req.pic=top.api.FileItem('abc.jpg',open('abc.jpg','rb'))
req.has_receipt=true
req.receipt_type="A"
req.receipt_other_type_desc="aaa"
req.receipt_info="bbb"
req.inventory="[{\"date\":2011-01-28,\"quota\":10},{\"date\":2011-01-29,\"quota\":10}]"
req.vendor="chinaonline"
req.out_rid="12345321"
req.room_switch_cal="[{\"date\":\"yyyy-MM-dd\",\"room_status\":2},{\"date\":\"yyyy-MM-dd\",\"room_status\":1}]"
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.xhotel.room.add");
add_param(pRequest,"hid","100000");
add_param(pRequest,"rid","100000");
add_param(pRequest,"title","aaa");
add_param(pRequest,"guide","aaa");
add_param(pRequest,"desc","bbb");
add_file_param(pRequest,"pic","文件内容");
add_param(pRequest,"has_receipt","true");
add_param(pRequest,"receipt_type","A");
add_param(pRequest,"receipt_other_type_desc","aaa");
add_param(pRequest,"receipt_info","bbb");
add_param(pRequest,"inventory","{"date":2011-01-28,"quota":10},{"date":2011-01-29,"quota":10}");
add_param(pRequest,"vendor","chinaonline");
add_param(pRequest,"out_rid","12345321");
add_param(pRequest,"room_switch_cal","{"date":"yyyy-MM-dd","room_status":2},{"date":"yyyy-MM-dd","room_status":1}");
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.xhotel.room.add', {
'hid':'100000',
'rid':'100000',
'title':'aaa',
'guide':'aaa',
'desc':'bbb',
'pic':'文件内容',
'has_receipt':'true',
'receipt_type':'A',
'receipt_other_type_desc':'aaa',
'receipt_info':'bbb',
'inventory':'{"date":2011-01-28,"quota":10},{"date":2011-01-29,"quota":10}',
'vendor':'chinaonline',
'out_rid':'12345321',
'room_switch_cal':'{"date":"yyyy-MM-dd","room_status":2},{"date":"yyyy-MM-dd","room_status":1}'
}, function(error, response) {
if (!error) console.log(response);
else console.log(error);
})