Test of WeChat development platform development

Source: Internet
Author: User
And the resulting open platform has recently become quite popular. I always wanted to try a platform. recently I had a good idea to implement it as soon as possible. Fortunately, I don't need any UI design. I just need to display the logic. In fact, if the public platform is just an open platform, and the resulting open platform has been very popular recently. I always wanted to try a platform. recently I had a good idea to implement it as soon as possible. Fortunately, I don't need any UI design. I just need to display the logic. In fact, if the public platform is just a platform for publishing information, that is, in the "Edit mode", there is no need to knock on the code. In the developer mode, developers need to design certain logic and code to implement specific functions. Next, let's talk about the start of development: 1. to develop a public platform, you must first have server resources. of course, the editing mode is not counted. The so-called editing mode is the public account that simply pushes a message every day. Various cloud servers of server resources are acceptable. we recommend BAE, SAE, nuts, and Alibaba. what are their respective advantages? There will be some free resources to deliver, and it is enough to use the trainer. A. apply for a BAE account and create an application. if the application is tested, download the PHP code from the homepage of the public platform and change the TOKEN to your own TOKEN. For example, in the following PHP test code, the logic of the code is clear, that is, a verification process can also define some logical operations. Upload this file and create your own app version 1:
 Valid (); class wechatCallbackapiTest {public function valid () {$ echoStr = $ _ GET ["echostr"]; // valid signature, option if ($ this-> checkSignature () {echo $ echoStr; exit ;}} public function responseMsg () {// get post data, may be due to the different environments $ postStr = $ GLOBALS ["HTTP_RAW_POST_DATA"]; // extract post data if (! Empty ($ postStr) {$ postObj = simplexml_load_string ($ postStr, 'simplexmlelement', LIBXML_NOCDATA); $ fromUsername = $ postObj-> FromUserName; $ toUsername = $ postObj-> ToUserName; $ keyword = trim ($ postObj-> Content); $ time = time (); $ textTpl ="
                               
  %s
                                
  %s
                                
  
   
% S
                                
  %s
                                
  %s
                                
  
   
0
                                
 "; If (! Empty ($ keyword) {$ msgType = "text"; $ contentStr = "Welcome to wechat world! "; $ ResultStr = sprintf ($ textTpl, $ fromUsername, $ toUsername, $ time, $ msgType, $ contentStr); echo $ resultStr;} else {echo" Input something... ";}} else {echo" "; exit ;}} private function checkSignature () {$ signature =$ _ GET [" signature "]; $ timestamp = $ _ GET ["timestamp"]; $ nonce = $ _ GET ["nonce"]; $ token = TOKEN; $ tmpArr = array ($ token, $ timestamp, $ nonce); sort ($ tmpArr); $ tmpStr = implode ($ tmpArr); $ tmpStr = sha1 ($ tmpStr); if ($ tmpStr = $ signature) {return true;} else {return false ;}}}

 

?> After the new version is successfully created, the application is successfully created:

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.