Today is the third day of my internship in Wusuo 12 God . We are in the middle of the day , Basically, the WeChat official account's message recovery and custom menu creation are basically realized. .

First , It's about message reply , The key points are as follows :

  1. Read POST Data flow from :Stream Data flow variables = HttpContext.Current.Request.InputStream, And put it in the array : Data flow variables .Read( An array variable , 0, (int) Data flow variables .Length) after , And then convert it to a string :string  String variable = Encoding.UTF8.GetString( An array variable ) .
  2. In the string converted from the data stream XML Nodes required in : The root node .SelectSingleNode("// The name of the node you want ").InnerText.
  3. With XML Document format returns message to wechat server ,XML The format is as follows ( Take text message as an example ):
     "<xml>"+
           "<ToUserName><![CDATA[" +  The user account + "]]></ToUserName>"+
           "<FromUserName><![CDATA[" +  Developer official account + "]]></FromUserName>"+
           "<CreateTime>" + DateTime.Now.Ticks.ToString() + "</CreateTime>"+
           "<MsgType><![CDATA[text]]></MsgType>"+
           "<Content><![CDATA["+ Content of reply +"]]></Content>"+
           "</xml>";

in addition , Yes, create a custom menu , The key points are as follows :

  1. Get interface credentials access_token, Send a request to https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid= Developer's own APPID&secret= Developer's own APPSECRET, You can get access_token character string . It should be noted that , This string is valid for two hours .
  2. Send a request to https://api.weixin.qq.com/cgi-bin/menu/create?access_token= What you get access_token. To send a request, use https agreement .
  3. With JSON The content and function of custom menu .

Today, the two development of WeChat public official account. , There are also some episodes . That is, after programming the code of custom menu , In the WeChat official account's developer center, when submitting changes to the server configuration, , All the time “ System error , Please try again later ”. When we think this experiment will fail again , It's strange to find that the custom menu in the service number has been created successfully . We went back to the website , Find out URL It's still the same , But after a while , Check it again , Find out URL It's changed , This makes us feel quite strange . I don't know , It's a code problem , Or wechat , I hope you can help me with the similar situation , thank you !

2014-07-24 .NET More information about WeChat official account's reply and custom menu.

  1. C# WeChat official account development -- ( 6、 ... and ) Custom menu events CLICK

    When WeChat official account, users click the button manually. , The official account of WeChat will passively send word messages or text messages to users. . adopt C# WeChat official account development -- ( 5、 ... and ) Custom menu creation   We've learned how to CLICK Type button to add to their own wechat public platform ...

  2. .NET WeChat official account development -2.0 Create a custom menu

    One . Preface Before development , We need to read the official interface documentation , I have to make complaints about it , The official document of wechat is really bad , however , In order to develop the functions we need , We also have to look at these documents . Interface document address :http://mp.weixin ...

  3. .NET WeChat official account development -3.0 Query custom menu

    One . Preface We have already created our custom menu . So how do we query our custom menu now . The principle is the same , And it's quite simple , It's just that the interface address document has been changed . 2.0 Start coding Similarly, we first create my query page , Here ...

  4. C# WeChat official account development -- ( 7、 ... and ) Custom menu events VIEW And web page (OAuth2.0) to grant authorization

    Popular speaking VIEW In fact, we are C# Commonly used a label , You can customize the menu directly URL Write the link that needs to jump in the attribute of , It is also a simple jump . But more often than not , We want to pass VIEW To enter the specified page and operate . Take a simple example ...

  5. C# WeChat official account development -- ( 5、 ... and ) Custom menu creation

    Official account , At the bottom are all function buttons with their own definition , Click a button to achieve the specified business logic operation . Let's talk about how these buttons are put on wechat public platform , Let's take a look at the official explanation of wechat first : Please note that : 1. Custom menus include at most 3 One level ...

  6. php Realization of message reply in WeChat official account And access_token

    // The code is as follows <?phpclass IndexAction extends Action { public function __construct(){ } public function i ...

  7. C# WeChat official account ( Solve the limit of only once a day )

    After a few days of studying the online code and Xie can's help , I finally used it today C# WeChat official account has been sent out. , Now tidy up . General idea :1. First, we must apply for a official account on the WeChat public platform. . 2. And then simulated landing .( Because I'm right http Transmission source ...

  8. Java WeChat official account security mode message decryption

    This article mainly introduces in detail Java WeChat official account security mode message decryption , It has certain reference value , Interested friends can refer to 1. Download and decrypt tools on wechat public platform , Import project , according to demo Decrypt the message public stat ...

  9. WeChat small program combined with WeChat official account for sending messages

    WeChat small program combined with WeChat official account for sending messages Because the template message of the applet has been discarded , Official use of subscription message function . However, the usage of subscription message is limited , Users have to subscribe . You need to get permission for users to accept messages . Users have to interact with applets ...

Random recommendation

  1. AngularJS Scope( Scope )

    1. AngularJS Scope( Scope ) Scope( Scope ) Is used in the HTML ( View ) and JavaScript ( controller ) The bond between . Scope It's an object , There are methods and properties available . Sc ...

  2. iOS How to distinguish network monitoring 2、3、4G?

    You can Github Download this Demo First , Introduction to the system Reachability class , If you don't know how to introduce it , stay Xcode, Press down shift+command+0, Search for Reachability, See the selected project in the figure ...

  3. Row column conversion pivot

    select * from ( select isnull(c.type,' other ') type,d from ( select ID,Record_code,code,day(thedate) d f ...

  4. The first 48 strip : If precise answers are needed , Please avoid using float and double

    float and double It is mainly designed for scientific calculation and engineering calculation , Performs binary floating point operations , It is carefully designed to provide more accurate and fast approximate calculation in a wide range of numerical values . However , They don't provide completely accurate results , So it's not suitable for the need for precision ...

  5. Wechat applet access html Post content display (C#)

    Use scenarios : Wechat applet Specific function : Get article content from server Show it in a small program Using language : C# -------------------------------------------------------- ...

  6. spring mvc Access to static resources

    If our project uses springmvc, stay web.xml There will be a section of this configuration . <servlet> <servlet-name>springMvc</servlet-na ...

  7. Python【 The fourth lesson 】 modular and package

    Content of this article Module foundation and import (import,from...import...) Package knowledge and import (import,from...import...) Functional class I object 1. Module foundation and import 1.1 Module understanding what ...

  8. Big data projects (MTDAP) Random thoughts

    Spark MLlib Conduct example When it comes to testing , Always fail to compile , Report less package <Spark MLlib NoClassDefFoundError: org/apache/spark/ml/param ...

  9. We can talk fedora23 Next Virutalbox Installation . -- The key to the problem is install kernel-devel package

    First , To use virutalbox Of rpm Installation package Installation . During the installation , If you are prompted There are some bags , No, , dependencies not resolved, such as libQt..libvpx ...

  10. CCCC L2-001 Emergency rescue floyd Changed dijkstra Templates ( Record path ) L3 Ladder map

    https://www.patest.cn/contests/gplt/L2-001 Answer key : Find the number of shortest paths , And output the path with the maximum weight of the point , use priority_queue Meeting wa Two points , Unknown cause . So I learned again ...