首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >WeChat不接受响应消息

WeChat不接受响应消息
EN

Stack Overflow用户
提问于 2014-04-11 07:27:19
回答 1查看 982关注 0票数 1

因此,我们在微信调试控制台中接受了我们的应用程序,并希望使用丰富的媒体类型消息进行响应。预期来自服务器的请求如下:

代码语言:javascript
复制
<xml>
   <ToUserName>UserName</ToUserName>
    <FromuserName>TestUser</FromuserName>
    <CreateTime>7200</CreateTime>
    <MsgId>12302</MsgId>
    <Content>Test Message</Content>
</xml>

对此,我们答复如下:

代码语言:javascript
复制
 <xml>
    <ToUserName>TestUser</ToUserName>
    <FromUserName>UserName</FromUserName>
    <CreateTime>7200</CreateTime>
    <MsgType>news</MsgType>
    <ArticleCount>1</ArticleCount>
    <Articles>
        <item>
             <Title>Test</Title>
             <Description>Test</Description>
             <PicUrl>http://PICURL</PicUrl>
             <Url>http://ARTICLE_URL</Url>
        </item>
    </Articles>
 </xml>

但是,应用程序在安装时似乎没有收到请求,所以问题是:

  1. 请求会转到URL设置吗?
  2. 如果是这样的话,xml是否为响应提供了正确的xml,对于发布到所提供的url的消息也是正确的?
  3. 请求中是否有特定的标头?
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2014-04-11 08:25:57

  1. 是的,请求将转到您设置的URL,并向脚本发送一个直接的XML帖子。
  2. 检查您的XML,似乎与实际的系统输入和输出有很大的不同,还可以检查工作输入和输出XML的示例,然后尝试一下。显然,它取代了ToUserName和FromUserName:

输入响应

代码语言:javascript
复制
    <xml>
        <ToUserName><![CDATA[gh_4456]]></ToUserName>
        <FromUserName><![CDATA[123abc]]></FromUserName> 
        <CreateTime>1397201326</CreateTime> 
        <MsgType><![CDATA[text]]></MsgType> 
        <Content><![CDATA[test]]></Content> 
        <MsgId>6000934001298302633</MsgId> 
    </xml> 

输出响应

代码语言:javascript
复制
    <xml> 
        <ToUserName><![CDATA[123abc]]></ToUserName> 
        <FromUserName><![CDATA[gh_4456]]></FromUserName> 
        <CreateTime>1397201781</CreateTime> 
        <MsgType><![CDATA[news]]></MsgType> 
        <ArticleCount>1</ArticleCount> 
        <Articles>
            <item> 
                <Title><![CDATA[Your test title]]></Title> 
                <Description><![CDATA[test description]]></Description> 
                <PicUrl><![CDATA[http://test.com/img.jpg]]></PicUrl> 
                <Url><![CDATA[http://test.com/]]></Url> 
            </item> 
        </Articles> 
    </xml>  
  1. 没有你需要担心的标题。

代码语言:javascript
复制
- FOR OFFICIAL OA: I think your problem might be that you have not enabled developer mode yet. Even though you have setup the URL and TOKEN. Please confirm developer mode is ENABLED. Go to admin.wechat.com -> login -> function -> advanced -> developer mode should be ENABLED.
- FOR SANDBOX ACCOUNT: developer mode is always enabled.
- Also check your CreateTime this should be a unix timestamp.
- If none of that resolves it go and look at your access logs. Find the URL wechat is posting to. Once you have the URL got to [http://www.hurl.it/](http://www.hurl.it/) change the destination type to POST and paste the URL there. Add a Header called "Content-Type" with the value "text/xml" click on add body and post your input response in there. This will give you the response that WeChat sees. I tested yours and found the ToUserName was blank, also ensure you don't have unneeded spaces or newlines there. 

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/23006165

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档