Skip to content

Messenger API mt

zjc1750514326 edited this page Jan 14, 2025 · 3 revisions

Messenger API Documentation

发送消息接口

发送消息

通过API发起Messenger消息发送服务

  • URL:https://api2.nxcloud.com/api/meta/mt
  • Method:POST
  • Content-Type:application/json
  • 需要鉴权:

鉴权机制

鉴权规则请参考地址:API接口调用约定

请求参数

参数名 类型 必填 描述
pageId String 公共主页id
recipientId String 接收方id
functionType String 消息类型
messageData Object 消息体参数
appkey String 应用唯一标识
productionType String 产品类型(messenger, instagram)

functionType 消息类型说明

类型 描述 必填参数
text 文本 messageData{rateType=Message,text不能为空}
image 图片 messageData{rateType=Message,image不能为空}
audio 音频 messageData{rateType=Message,url不能为空}
video 视频 messageData{rateType=Message,url不能为空}
template 普通模板 messageData{rateType=Message,title不能为空}
button_template 按钮模板 messageData{rateType=Message,text/elements不能为空}

messageData 消息体参数说明

参数名 类型 必填 描述
rateType String 计费类型(Message)
text String 文本内容
url String 地址(根据functionType确定是图片/音频/视频地址)
type String 类型(当functionType为template特有,generic/button)
elements Array 元素数组

rateType 计费类型说明

类型 描述
Message 消息

elements 元素参数说明

参数名 类型 必填 描述
title String 标题(type=generic时必填)
subtile String 子标题
imageUrl String 图片地址
buttons Array 按钮数组(type=button时必填)

buttons 按钮参数说明

参数名 类型 必填 描述
type String 类型(web_url/postback)
url String 跳转地址
title String button名称

请求示例

发送文本消息

{
  "appkey": "your_app_key",
  "pageId": "your_page_id",
  "recipientId": "recipient_id",
  "functionType": "text",
  "productionType": "messenger",
  "messageData": {
    "text": "Hello World!",
    "rateType": "Promotional"
  }
}

发送图片消息

{
  "appkey": "your_app_key",
  "pageId": "your_page_id",
  "recipientId": "recipient_id",
  "functionType": "image",
  "productionType": "messenger",
  "messageData": {
    "url": "your_url",
    "rateType": "Message"
  }
}

发送音频消息

{
  "appkey": "your_app_key",
  "pageId": "your_page_id",
  "recipientId": "recipient_id",
  "functionType": "audio",
  "productionType": "messenger",
  "messageData": {
    "url": "your_audio_url",
    "rateType": "Message"
  }
}

发送视频消息

{
  "appkey": "your_app_key",
  "pageId": "your_page_id",
  "recipientId": "recipient_id",
  "functionType": "video",
  "productionType": "messenger",
  "messageData": {
    "url": "your_video_url",
    "rateType": "Message"
  }
}

发送普通模板消息

{
  "appkey": "your_app_key",
  "pageId": "your_page_id",
  "recipientId": "recipient_id",
  "functionType": "template",
  "productionType": "messenger",
  "messageData": {
    "elements": [
      {
        "title": "Welcome!",
        "image_url": "https://example.com/image.jpg",
        "subtitle": "We have the right hat for everyone.",
        "action": {
          "type": "web_url",
          "url": "https://www.example.com"
        },
        "buttons": [
          {
            "type": "web_url",
            "url": "https://www.example.com",
            "title": "View Website"
          }
        ]
      }
    ],
    "type": "generic",
    "rateType": "Message"
  }
}

发送按钮模板消息

{
  "appkey": "your_app_key",
  "pageId": "your_page_id",
  "recipientId": "recipient_id",
  "functionType": "button_template",
  "productionType": "messenger",
  "messageData": {
    "text": "button template",
    "elements": [
      {
        "buttons": [
          {
            "type": "web_url",
            "url": "https://www.example.com",
            "title": "访问网站"
          },
          {
            "type": "postback",
            "payload": "POSTBACK_PAYLOAD",
            "title": "回调按钮"
          }
        ]
      }
    ],
    "type": "button",
    "rateType": "Message"
  }
}

响应参数

参数名 类型 描述
code Integer 响应码
msg String 响应描述
data Object 响应数据

响应示例

{
  "code": 200,
  "msg": "success",
  "data": {
    "messageId": "msg123456789"
  }
}

错误码说明

错误码 描述
200 成功
400 参数错误
401 未授权
403 禁止访问
500 服务器错误

简介

短信

语音

云呼叫中心(NXLink)

云呼叫中心(AI自动外呼)

Flash Call

短链

邮件验证码

DID号码

通用

号码检测

WhatsApp

Viber

Zalo ZNS

Super Message API

隐私号(旧)

PNS

坐席(旧版)

AI Agent

Clone this wiki locally