文档中心 > API类目 > 消息服务API

taobao.tmc.messages.produce (批量发送消息)

批量发送消息

公共参数

请求参数

名称 类型 是否必须 示例值 更多限制 描述
messages TmcPublishMessage [] 必须
  • 最大列表长度:50
  • tmc消息列表, 最多50条,元素结构与taobao.tmc.message.produce一致,用json表示的消息列表。例如:[{"content": "{\"tid\":1234554321,\"status\":\"X_LOGISTICS_PRINTED\",\"action_time\":\"2014-08-08 18:24:00\",\"seller_nick\": \"向阳aa\",\"operator\":\"小张\"}","topic": "taobao_jds_TradeTrace"},{"content": "{\"tid\":1234554321,\"status\":\"X_LOGISTICS_PRINTED\",\"action_time\":\"2014-08-08 18:24:00\",\"seller_nick\": \"向阳aa\",\"operator\":\"小张\"}","topic": "taobao_jds_TradeTrace"}]
    • └ content
    • String
    • 必须
    • {"tid":2895732958732,"seller_nick":"helloworld"}
    • 消息内容的JSON表述,必须按照topic的定义来填充
    • └ target_group
    • String
    • 可选
    • default
    • 目标分组
    • └ topic
    • String
    • 必须
    • taobao_trade_TradeCreate
    • 消息类型

    响应参数

    名称 类型 示例值 描述
    is_all_success Boolean true 是否全部成功
    results TmcProduceResult [] 发送结果,与发送时的参数顺序一致。如果is_all_success为true时,不用校验result是否成功
    • └ error_code
    • String
    • isv.invalid-paramter
    • 错误码
    • └ error_message
    • String
    • parameter required
    • 错误信息
    • └ is_success
    • Boolean
    • true
    • 是否成功

    请求示例

    • JAVA
    • .NET
    • PHP
    • CURL
    • Python
    • C/C++
    • NodeJS
    TaobaoClient client = new DefaultTaobaoClient(url, appkey, secret);
    TmcMessagesProduceRequest req = new TmcMessagesProduceRequest();
    List<TmcMessagesProduceRequest.TmcPublishMessage> list2 = new ArrayList<TmcMessagesProduceRequest.TmcPublishMessage>();
    TmcMessagesProduceRequest.TmcPublishMessage obj3 = new TmcMessagesProduceRequest.TmcPublishMessage();
    list2.add(obj3);
    obj3.setContent("{\"tid\":2895732958732,\"seller_nick\":\"helloworld\"}");
    obj3.setJsonExContent("{\"full_link_test\":true}");
    obj3.setTargetAppKey("12345678");
    obj3.setTargetGroup("default");
    obj3.setTopic("taobao_trade_TradeCreate");
    req.setMessages(list2);
    TmcMessagesProduceResponse rsp = client.execute(req, sessionKey);
    System.out.println(rsp.getBody());

    响应示例

    • XML示例
    • JSON示例
    <tmc_messages_produce_response>
        <is_all_success>true</is_all_success>
        <results>
            <tmc_produce_result>
                <error_code>isv.invalid-paramter</error_code>
                <error_message>parameter required</error_message>
                <is_success>true</is_success>
            </tmc_produce_result>
        </results>
    </tmc_messages_produce_response>

    异常示例

    • XML示例
    • JSON示例
    <error_response>
        <code>50</code>
        <msg>Remote service error</msg>
        <sub_code>isv.invalid-parameter</sub_code>
        <sub_msg>非法参数</sub_msg>
    </error_response>

    错误码解释

    错误码 错误描述 解决方案

    API工具

    如何获得此API

    FAQ

    返回
    顶部