Php WeChat development platform development quiz

Source: Internet
Author: User
Php development platform development is a small experiment 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 a platform for publishing information, that is, in the "Editing mode", it does not need to be tested on the php development platform.
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 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 start with the 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 it from the homepage of the public platform. PHP code, You only need to 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, optionif ($ 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 dataif (! 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"; (PS: ^ _ ^ good php learning exchange group: 276167802, verification: csl, if you are interested, join in and discuss) $ 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:

Hope this article Php developersThanks for reading this article.

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.