微信开发系列之一 - 微信公众号开发的开发环境搭建-阿里云开发者社区

开发者社区> jerrywangsap> 正文

微信开发系列之一 - 微信公众号开发的开发环境搭建

简介: 微信开发系列之一 - 微信公众号开发的开发环境搭建
+关注继续查看

文章系列目录

Wechat development series 1 – setup your development environment

Wechat development series 2 – development Q&A service using nodejs

Wechat development series 3 – Trigger C4C Account creation in Wechat app

Wechat development series 4 – Send C4C Data change notification to Wechat app

Wechat development series 5 – embedded your UI5 application to Wechat app

Wechat development series 6 – Retrieve Wechat User info via oAuth2 and display it in UI5 application

Wechat development series 7 – use Redis to store Wechat conversation history

Wechat development series 8 – Map integration

Wechat development series 9 – Create C4C Social Media Message and Service within Wechat app

Wechat development series 10 – Use Wechat app to receive Service Request reply made from C4C

Tencent’s WeChat, a social networking app with more than 760 million monthly active users, is becoming a dominant mobile channel connecting businesses and customers. This series will illustrate how to do some development on Wechat so it could interact with SAP product like SAP Cloud for Customer.


Prerequisite

(1) You should have already registered an subscription account in Wechat Official Account platform: https://mp.weixin.qq.com

(2) You should have basic knoledge about nodejs development.

Detail steps for environment setup

Log on to Official Account platform https://mp.weixin.qq.com, menu Development->Basic configuration,


image.png


The most important setting here is the server url, where the custom logic of your Wechat official subscription account is hosted.


image.png


In this series, I will use nodejs plus Heroku to host the server. This server is responsible to serve the request which is delegated by Wechat platform issued originally by your Wechat official subscription account’s followers. Before Wechat platform will really delegate user request to this server, you must first pass the verification defined by Wechat’s development guide: https://mp.weixin.qq.com/wiki?t=resource/res_main&id=mp1472017492_58YV5

Unfortunately the verification flow chart in the guide is drawn with Chinese text:

image.png


And the provided sample code is written by Python, so here I will provide a nodejs solution instead.


As long as you press “Submit” button, Wechat platform will send a http request to the server specified via this URL:


image.png


The http request looks like below:


https:///?signature=096abd439b41f9610aeabe2d7534084fd8dafa20&echostr=16168327802220428137&timestamp=1512810825&nonce=384289189


The responsibility of your server is then to calculate a result based on your subscription account token, the timestamp and the nonce field, and compare it with the echostr passed with the request url. If the comparison result is not equal, you will see error message “Token authentication failed”.


image.png


Only after your server has passed the verification then it is ready for subsequent development.


Below is the step how to develop your server to pass the verification.


(1) Create a new nodejs project with the following package.json. The highlighted part is relevant for server verification.


image.png


(2) Implement server.js with following source code:

image.png

(3) deploy this nodejs application to Heroku. For detail steps, please refer to my blog Step by step to host your UI5 application in Heroku.


Once done, perform the verification in Wechat Official Account platform.


Then in Heroku application console we can see that the signature passed from Wechat platform is equal to the value calculated in our nodejs server, as a result the verification is finished successfully:


image.png


You can see now the Server configuration in Wechat platform is marked as enabled, which is ready for subsequent development.


image.png

版权声明:本文内容由阿里云实名注册用户自发贡献,版权归原作者所有,阿里云开发者社区不拥有其著作权,亦不承担相应法律责任。具体规则请查看《阿里云开发者社区用户服务协议》和《阿里云开发者社区知识产权保护指引》。如果您发现本社区中有涉嫌抄袭的内容,填写侵权投诉表单进行举报,一经查实,本社区将立刻删除涉嫌侵权内容。

相关文章
阿里云服务器怎么设置密码?怎么停机?怎么重启服务器?
如果在创建实例时没有设置密码,或者密码丢失,您可以在控制台上重新设置实例的登录密码。本文仅描述如何在 ECS 管理控制台上修改实例登录密码。
9496 0
快速进行ECS服务器后端开发环境搭建工作
在后端的学习过程中,使用将工程部署在服务器上往往是学习中最琐碎最不容易引人注目的环节,但是这一环节又是至关重要的,本文将介绍使用Oneinstack进行服务器快速环境搭建,以及使用阿里行云和飞流进行代码自动测试构建流水线部署的快捷方式。
124 0
JFinal开发环境搭建,JFinal开发案例
 JFinal  是基于 Java  语言的极速  WEB  + ORM  开发框架,其核心设计目标是开发迅速、代码量少、学习简单、功能强大、轻量级、易扩展、Restful。在拥有Java 语言所有优势的同时再拥有 ruby、python、php 等动态语言的开发效率! JFinal 有如下主要特点:l  MVC 架构,设计精巧,使用简单l  遵循 COC 原则,零配置,无 xmll  独
1809 0
阿里云本地开发环境搭建
简述阿里云本地开发环境的搭建
3149 0
阿里云服务器如何登录?阿里云服务器的三种登录方法
购买阿里云ECS云服务器后如何登录?场景不同,阿里云优惠总结大概有三种登录方式: 登录到ECS云服务器控制台 在ECS云服务器控制台用户可以更改密码、更换系.
13186 0
Mac下Android Studio 3.x的NDK开发环境搭建
目录 前言 CMake 用CMake向已有AS项目添加C/C++代码 ndk-build 最后 前言 mac上安装软件真的很简单, 一路下一步就可以安装好android studio. 这里有一篇旧文-Mac下安装配置Android Studio 2.
2051 0
OK335xS Ubuntu 12.04.1 版本 Android 开发环境搭建
/******************************************************************************************** * OK335xS Ubuntu 12.
1070 0
+关注
2628
文章
0
问答
来源圈子
更多
+ 订阅
文章排行榜
最热
最新
相关电子书
更多
《2021云上架构与运维峰会演讲合集》
立即下载
《零基础CSS入门教程》
立即下载
《零基础HTML入门教程》
立即下载