because ASP Program development has many advantages , Early years ASP Popular all over the world , So it's still in operation today ASP The development project is still running , But as social networks continue to grow , Especially wechat payment 、 Wechat communication 、 The emergence of small programs and so on , Lead to many ASP It's embarrassing to connect projects . And wechat doesn't aim at ASP A detailed description of the project development , This can only rely on the skilled technicians 、 Rich technical experience to complete the docking . But there's a lot more to take over ASP It's troublesome to connect old projects .

Today I'll take time to ASP Some common applications for secondary development with wechat service number , Encapsulation is DLL To form a , You only need to be familiar with some basic interface information of this organization , It's easy ASP Perfect connection between old projects and wechat service number , And the simplest way .

Organization name :WeixinDLL

This build provides 2 Classes :( Let's start with the basic information about classes , The following function is introduced with a case )

One 、 The class that communicates with wechat :WeixinClass

Two 、 WeChat V3 payment MD5 Encryption class :Md5Class

WeixinClass Common functions to achieve :

1、 Wechat service number customer login , And obtain the basic information of users authorized by customers

2、 Judge whether the customer is concerned about the official account of WeChat

3、 Wechat sharing ( Share with wechat friends 、 WeChat friend circle 、QQ Good friends 、QQ Circle of friends, etc )

4、 Access the precise positioning of customers ( just / Reverse geocoding to get the detailed address , Accurate to street number )

5、 Automatically send wechat template messages to customers

6、 Automatically send wechat text messages to customers

7、 Automatically send wechat text messages to customers ( Similar to wechat chat information )

8、 Wechat online payment (V3 payment )

WeixinClass Provided function

1、XMLRequest(ByVal prepay_id_url, ByVal xmlBody)

prepay_id_url: Wechat server authentication prepay_id Of url Address

xmlBody: Submitted to wechat server xml Format content

The main purpose of this function is to get the prepay_id such XML request , Requests requiring certificate authentication . What we get is a string that has been authenticated and encrypted with the wechat server , Easy to initiate JSAPI Payment function .

2、ToUnixTime(ByVal strTime)

This is mainly for the conversion of ordinary date to time stamp

3、MakeRanNum(ByVal Length)

Returns the random number of a combination of pure numbers , The length is length, It can be set at will

4、MakeRanNumChar(ByVal Length)

Return to digital 、 Mixed uppercase and lowercase string , The length is length, It can be set at will

5、parseJSON(ByVal str)

Will receive JavaScript Of Json Format content , adopt parseJSON stay ASP It can be similar in code JS Making object mode calls .

6、file_get_contents(ByVal url, ByVal method, ByVal postdata)

url: Web address submitted

method: submission post/get

postdata: Data submitted , It can be json, It could be something else

Returns the feedback content of the communication on the remote server

7、get_paySign(ByVal snonce_str, ByVal sprepay_id, ByVal stimeStamp)

snonce_str: Random string

sprepay_id: Encryption after digital certificate authentication prepay_id

stimeStamp: Time stamp

Wechat payment V3, Return to last submitted paySign

8、get_prepay_id(ByVal attach, ByVal body, ByVal nonce_str, ByVal notify_url, ByVal openid, ByVal out_trade_no, ByVal total_fee)

Purpose : Wechat payment V3 obtain Prepay_Id

attach: Additional data , It is mainly used for notify Process of data operation

body: Order content

nonce_str: Random string ( commonly 12 A bit is enough )

notify_url: After successful payment , The program page address of wechat server and our server for communication

openid: The customer who initiated the payment openid

out_trade_no: The order no. ( Just set a number that doesn't repeat , Pure number or alphanumeric combination )

total_fee: Pay the amount ( Remember to multiply it 100, Remember to divide by 100)


Get general access_token, This is the same as when the customer authorizes personal basic data to a third party access_token Somewhat different , Don't confuse them

10、Get_Ticket(ByVal AccessToken)

Get the latest jsapi_ticket, Variable :AccessToken It belongs to general purpose access_token

11、Get_RedirectUrl(ByVal CallUrl)

Encapsulated login or authorization URL, Return a message after communicating with wechat server code Back to callUrl Inside .

12、Get_Token_OpenID(ByVal Code)

Get_Token_OpenID: return Json data
You can get token、openid
Get the user's token And general token It's different ( If there is no third party development , Unable to get user UnionID)
Put it back correctly :{ "access_token":"ACCESS_TOKEN", "expires_in":7200, "refresh_token":"REFRESH_TOKEN", "openid":"OPENID", "scope":"SCOPE" }
Erroneous return :{" errcode":40029,"errmsg":"invalid code" }

13、GetUserInfo(ByVal token_openid_Json)

GetUserInfo: Return user information Json

Get the user's nickname 、 Gender 、 Country 、 Province 、 City 、 Head portrait

sex : Gender of user , The value is 1 It's male , The value is 2 It was a woman , The value is 0 Time is unknown headimgurl:******/46 { The avatars , The last value represents the size of the square head ( Yes 0、46、64、96、132 Value optional ,0 representative 640*640 Square head ),

This item is empty when the user does not have a picture . If the user changes the Avatar , Original head URL Will fail .}

privilege : User privilege information ,json Array , For example, wechat Waka users are (chinaunicom)

unionid : Only when users bind the official account to WeChat open platform account. , This field will appear .

14、WxSend(ByVal u_openid, ByVal u_token, ByVal u_text)

Send plain text messages
POST Mode request
u_openid: user openid
u_token: Universal token
u_text: Sent content

15、SendPicText(ByVal u_openid, ByVal u_token, ByVal u_title, ByVal u_description, ByVal u_url, ByVal img_url)

Send text template information
POST Mode request
u_openid: user openid
u_token: Universal token
u_title: title
u_description: describe
u_url: Jump address
img_url: thumbnail

16、SendModeMessege(ByVal iopenid, ByVal itemplate_id, ByVal iurl, ByVal itopcolor, ByVal idata, ByVal itoken)

POST Mode request
iopenid: user openid
itemplate_id: Templates ID
iurl: Click on the message to jump to url
itopcolor: Title Color
idata: Template format data (Json Format )
itoken: Universal token

17、IfCancelWX(ByVal u_openid, ByVal u_token)

Check whether to cancel WeChat official account
1 = Focus on ,0 = Cancel the attention ,2 = illegal openid

All of the above are Function function , And they are Public Public function , There are also some more complex algorithms Private Function or Sub The function is not written , External cannot be called separately , It's all cooperation Public Some functions or methods of functions .

The next blog post is aimed at WeixinDLL The application of the method in this build is introduced , The code will be displayed directly .

There are shortcomings , Let's give more advice ,ASP Technical discussion on the docking development of the project and wechat service number can be added V Letter :z18670092211

ASP Program items and wechat service number ( official account ) Perfect combination . Just one DLL To form a WeixinDLL More articles about

  1. .NET Core The official account of WeChat payment 、H5 Payment

    Preface This article mainly records the official account number of WeChat payment. H5 Payment process . Preparation Official account or service number ( And open wechat payment function ). Open in merchant platform JSAPI payment .H5 payment . Configuration article The official account or service number. ------- Development ----- ...

  2. Wechat open platform Official account third party platform development Lesson four Calling the interface on behalf of the official account SDK and demo

    original text : Wechat open platform Official account third party platform development Lesson four Calling the interface on behalf of the official account SDK and demo Tutorial navigation : Wechat open platform Official account third party platform development Course one Platform is introduced Wechat open platform Official account third party platform development Tutorial 2 establish ...

  3. The official account of WeChat series Token verification

    The official account of WeChat series Token verification pycharm Development of online server Development process notes Reference material python3 install You can choose to install `pip install pyc ...

  4. Wechat payment ( Official account payment APIJS、app payment ) Server side unified single interface java edition

    One . WeChat official account payment APIJS: To achieve the complete wechat payment function , It needs to be implemented at the front and back end together , It also needs the configuration of wechat merchant platform . This is just the server code . jar package :pom.xml <!-- ↓↓↓↓↓↓↓↓ Payment related ...

  5. Wechat program development series ( Four ) Use wechat API Create official account custom menu

    You may see WeChat's official account with powerful menu. , After clicking, you can access many useful functions . This tutorial will teach you how to do it . The final effect of this tutorial is : Create a first level menu "UI5", ...

  6. 【weixin】 What is the difference and relationship between WeChat enterprise number and official account number? ?

    In the era of the rapid development of mobile Internet and the widespread application of smart phones , With the continuous expansion of wechat platform applications and the rapid increase of wechat users , WeChat official account has also made great progress in its operation. , Enterprises . Institutions and individuals have entered the ranks of WeChat official account. . The official account of WeChat is in WeChat public. ...

  7. 【 WeChat SEO】 The official account can also be ranked. ?

    [ Written in 2016 year 8 month ] lately , Wechat team issues an announcement , Open official account operators change official account name once a year. , This is a wonderful name for many names ( Include dkplus) The official account is a good thing. . Why is it a good thing ? The name of the official account is directly related to the name. ...

  8. .net Wechat payment ( Official account payment ) Problems encountered

    I don't want to talk about anything. Brick movers know what the boss says Recently, my boss asked me to do a wechat payment function   It also brings the kind of crowd funding activities of Jingdong on wechat , I buy things that people pay for Then pay with a micro-channel I haven't done this before as a novice So it's estimated that in the process ...

  9. 【 Wechat payment 】 official account 、 Merchant basic configuration and process ( Including setting the payment authorization directory 、 Test payment directory and white list 、JS Interface security domain name 、 Authorization callback domain name, etc )

    One . Use scenarios and instructions Use scenarios : The merchant has H5 Mall website , When the user opens the web page in wechat through message or scanning QR code , You can call wechat payment to complete the purchase process . explain :1. Users can open text messages or scan QR code , Open the Internet with a built-in browser on wechat ...

  10. 【 Wechat payment 】 official account JSAPI payment HTML5( Use MUI The front frame )+WebApi Implementation process

    Necessary parameters :      1) AppID,AppSecret : Background management in WeChat public official account —>( menu bar ) Development —> Basic settings     2) Merchant number : Background management in WeChat public official account —>( menu bar ) Wechat branch ...

Random recommendation

  1. Python Black hat programming 2.2 value type

    Python Black hat programming 2.2  value type value type , To put it bluntly, it's dealing with all kinds of numbers ,Python The numeric types in include integers . Long integer . Boolean . Double precision floating point . Decimal floating point and complex number , These types are different from traditional ones in many ways C The type has a large area ...

  2. js Judge mobile devices 、pc End 、android、iPhone、 Is it wechat 、 Microblogging 、qq Space

    varbrowser = {   versions: function () {      var u = navigator.userAgent, app = navigator.appVersio ...

  3. AtCoder Grand Contest 008 A

    Problem Statement Snuke has a calculator. It has a display and two buttons. Initially, the display s ...

  4. make Two forms of automatically generating dependent files

    Recently compiled source file found that after modifying header file ,make Does not automatically recompile all source files that contain this header file , Each time, you need to clear the corresponding intermediate file before recompiling , Very troublesome . Therefore need make Automatically manage the header file that the source file depends on , ...

  5. ArcObject10.1 Demote to 10.0

    First contact ArcGIS The version is 9.3, It's also installed for your needs 9.2 Development : Because my computer configuration is low , So I can't run 10.0 Chinese version : After graduation , In industry use 10.1 Mostly ( although 10.3 Has the ): Now? 10.4 It's all coming out : because ...

  6. C# The difference between reference type and value type in coding

    One . Introduction of import type and value type Value type : Store it directly in the stack , The value is obtained directly . Value types inherit from System.ValueType.( Custom object ) Reference type : Exists in the managed heap , When fetching, the address of the object is fetched from the stack , Then use this ...

  7. python cmd modular

    command Module is used to execute simple system commands specified as strings , And return its output as a string . This module is in the unix It works on the system . This model provides the same functions as in unix shell Back quotes used by scripts ( Namely ~ The reverse under this key ...

  8. troubleshooting : What is it? The server port was damaged telnet Failure ?( turn )

    telnet The main function of the command is to communicate with the target port TCP Connect ( That is to finish TCP Three handshakes ). When the server is started , however telnet The port on which it listens , But failed . perhaps , When the server runs for a period of time , The port on which it is listening telnet It doesn't work ...

  9. UBUNTU How to change mysql Default folder data folder

    stop it mysql maintenance * sudo /etc/init.d/mysql stop A copy of the original folder * cp -r /var/lib/mysql /home/yourname/somewhere The right to change ...

  10. Section 11 , utilize yolov3 Train your own dataset

    1. Environment configuration tensorflow1.12.0 Opencv3.4.2 keras pycharm 2. To configure yolov3 download yolov3 Code : ...