TaobaoClient client = new DefaultTaobaoClient(url, appkey, secret);
TpnTemplateMessageSendRequest req = new TpnTemplateMessageSendRequest();
req.setTemplateKey("xxxx");
req.setMobileBizDataString("{\"key1\":\"value\",\"key2\":123}");
req.setBizDataString("{\"key1\":\"value\",\"key2\":123}");
req.setTemplateId(101L);
req.setPicture("http://xxx");
req.setPict("http://xxx");
req.setUserId(12345L);
req.setSubUserId(123456L);
req.setTitleParamString("{\"key1\":\"value\",\"key2\":123}");
req.setBizId(122323434545L);
req.setContentParamString("{\"key1\":\"value\",\"key2\":123}");
TpnTemplateMessageSendResponse rsp = client.execute(req);
System.out.println(rsp.getBody());
ITopClient client = new DefaultTopClient(url, appkey, secret);
TpnTemplateMessageSendRequest req = new TpnTemplateMessageSendRequest();
req.TemplateKey = "xxxx";
req.MobileBizData = "{\"key1\":\"value\",\"key2\":123}";
req.BizData = "{\"key1\":\"value\",\"key2\":123}";
req.TemplateId = 101L;
req.Picture = "http://xxx";
req.Pict = "http://xxx";
req.UserId = 12345L;
req.SubUserId = 123456L;
req.TitleParam = "{\"key1\":\"value\",\"key2\":123}";
req.BizId = 122323434545L;
req.ContentParam = "{\"key1\":\"value\",\"key2\":123}";
TpnTemplateMessageSendResponse rsp = client.Execute(req);
Console.WriteLine(rsp.Body);
$c = new TopClient;
$c->appkey = $appkey;
$c->secretKey = $secret;
$req = new TpnTemplateMessageSendRequest;
$req->setTemplateKey("xxxx");
$req->setMobileBizData("{\"key1\":\"value\",\"key2\":123}");
$req->setBizData("{\"key1\":\"value\",\"key2\":123}");
$req->setTemplateId("101");
$req->setPicture("http://xxx");
$req->setPict("http://xxx");
$req->setUserId("12345");
$req->setSubUserId("123456");
$req->setTitleParam("{\"key1\":\"value\",\"key2\":123}");
$req->setBizId("122323434545");
$req->setContentParam("{\"key1\":\"value\",\"key2\":123}");
$resp = $c->execute($req);
curl -X POST 'http://gw.api.taobao.com/router/rest' \
-H 'Content-Type:application/x-www-form-urlencoded;charset=utf-8' \
-d 'app_key=12129701' \
-d 'format=json' \
-d 'method=taobao.tpn.template.message.send' \
-d 'partner_id=apidoc' \
-d 'sign=44867632C0604CF3684BA7F133E9B3C5' \
-d 'sign_method=hmac' \
-d 'timestamp=2025-05-08+03%3A08%3A19' \
-d 'v=2.0' \
-d 'biz_data=%7B%5C%22key1%5C%22%3A%5C%22value%5C%22%2C%5C%22key2%5C%22%3A123%7D' \
-d 'biz_id=122323434545' \
-d 'content_param=%7B%5C%22key1%5C%22%3A%5C%22value%5C%22%2C%5C%22key2%5C%22%3A123%7D' \
-d 'mobile_biz_data=%7B%5C%22key1%5C%22%3A%5C%22value%5C%22%2C%5C%22key2%5C%22%3A123%7D' \
-d 'pict=http%3A%2F%2Fxxx' \
-d 'picture=http%3A%2F%2Fxxx' \
-d 'sub_user_id=123456' \
-d 'template_id=101' \
-d 'template_key=xxxx' \
-d 'title_param=%7B%5C%22key1%5C%22%3A%5C%22value%5C%22%2C%5C%22key2%5C%22%3A123%7D' \
-d 'user_id=12345'
# -*- coding: utf-8 -*-
import top.api
req=top.api.TpnTemplateMessageSendRequest(url,port)
req.set_app_info(top.appinfo(appkey,secret))
req.template_key="xxxx"
req.mobile_biz_data="{\"key1\":\"value\",\"key2\":123}"
req.biz_data="{\"key1\":\"value\",\"key2\":123}"
req.template_id=101
req.picture="http://xxx"
req.pict="http://xxx"
req.user_id=12345
req.sub_user_id=123456
req.title_param="{\"key1\":\"value\",\"key2\":123}"
req.biz_id=122323434545
req.content_param="{\"key1\":\"value\",\"key2\":123}"
try:
resp= req.getResponse()
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.tpn.template.message.send");
add_param(pRequest,"template_key","xxxx");
add_param(pRequest,"mobile_biz_data","{\"key1\":\"value\",\"key2\":123}");
add_param(pRequest,"biz_data","{\"key1\":\"value\",\"key2\":123}");
add_param(pRequest,"template_id","101");
add_param(pRequest,"picture","http://xxx");
add_param(pRequest,"pict","http://xxx");
add_param(pRequest,"user_id","12345");
add_param(pRequest,"sub_user_id","123456");
add_param(pRequest,"title_param","{\"key1\":\"value\",\"key2\":123}");
add_param(pRequest,"biz_id","122323434545");
add_param(pRequest,"content_param","{\"key1\":\"value\",\"key2\":123}");
pResponse = top_execute(pClient,pRequest,NULL);
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.tpn.template.message.send', {
'template_key':'xxxx',
'mobile_biz_data':'{\"key1\":\"value\",\"key2\":123}',
'biz_data':'{\"key1\":\"value\",\"key2\":123}',
'template_id':'101',
'picture':'http://xxx',
'pict':'http://xxx',
'user_id':'12345',
'sub_user_id':'123456',
'title_param':'{\"key1\":\"value\",\"key2\":123}',
'biz_id':'122323434545',
'content_param':'{\"key1\":\"value\",\"key2\":123}'
}, function(error, response) {
if (!error) console.log(response);
else console.log(error);
})