ToUserName与FromUserName的意思

在接收到微信推送的消息中tousername、fromusername的顺序与平台返回给微信(即要发送给微信用户)的交互信息中tousername、fromusername的值是相反的

  • 接受到的消息中:tousername=开发者公众号,fromusername=openid
  • 发送给微信的消息中:tousername=openid,fromusername=开发者的公账号

收包消息模板:

< >
  <ToUserName><![CDATA[微信开发者公众号-公众号的微信号]]></ToUserName>
  <FromUserName><![CDATA[fromUser]]></FromUserName>
  <CreateTime>1348831860</CreateTime>
  <MsgType><![CDATA[text]]></MsgType>
  <Content><![CDATA[this is a test]]></Content>
  <MsgId>1234567890123456</MsgId>
</ >

发包消息模板:

< >
  <ToUserName><![CDATA[openid]]></ToUserName>
  <FromUserName><![CDATA[微信开发者公众号-公众号的微信号]]></FromUserName>
  <CreateTime>12345678</CreateTime>
  <MsgType><![CDATA[text]]></MsgType>
  <Content><![CDATA[你好]]></Content>
</ >
收藏 打印