


WeChat payment development (6) Receiving address sharing interface, WeChat payment interface development_PHP tutorial
Jul 12, 2016 am 08:55 AMWeChat payment development (6) delivery address sharing interface, WeChat payment interface development
Keywords: WeChat payment delivery address sharing
Author: Fangbei Studio
Original text: http://www.cnblogs.com/txw1958/p/weixin-editAddress.html
This article introduces the development process of the delivery address sharing interface under WeChat payment.
1. Introduction
WeChat delivery address sharing means that users open a webpage in the WeChat browser and fill in the address. They can then quickly select without filling in the address, and can also add and edit it. This address is a user attribute and can be shared on the web pages of various merchants. Support native controls to fill in addresses, and the address data will be passed to the merchant.
Address sharing is based on the WeChat JavaScript API and can only be used in the WeChat built-in browser. Calls from other browsers are invalid. At the same time, WeChat version 5.0 is required to support it. It is recommended to use the user agent to determine the user's current version number before calling the address interface. Taking the iPhone version as an example, you can obtain the following WeChat version example information through useragent: "Mozilla/5.0(iphone;CPU iphone OS 5_1_1 like Mac OS For the version number of WeChat installed by the user, the merchant can determine whether the version number is higher than or equal to 5.0.
Address format
The data fields used for WeChat address sharing include:
- Consignee’s name
- Regions, provinces and municipalities at three levels
- Detailed address
- Postcode
- Contact number
Among them, the region corresponds to the national standard three-level area code, such as "Guangdong Province-Guangzhou City-Tianhe District", and the corresponding postal code is 510630. Reference link for details: http://www.stats.gov.cn/tjsj/tjbz/xzqhdm/201401/t20140116_501070.html
2. OAuth2.0 authorization
Before obtaining the delivery address, you need to call the login authorization interface to obtain an OAuth2.0 Access Token. Therefore, authorization needs to be done once, and the confirmation box will not pop up for this authorization.
The essence is that when the user accesses
http:<span>//</span><span>www.fangbei.org/wxpay/js_api_call.php</span>Jump to
when
https:<span>//</span><span>open.weixin.qq.com/connect/oauth2/authorize?appid=wx8888888888888888&redirect_uri=http://www.fangbei.org/wxpay/js_api_call.php&response_type=code&scope=snsapi_base&state=STATE#wechat_redirect</span>
Use this to obtain the code parameter, and obtain the authorized access_token and openid based on the code. This access token will be used for the delivery address sharing interface.
For the detailed process of its implementation, please refer to WeChat Public Platform Development (71) OAuth2.0 Web Authorization
2. Get random string
The method to generate a random string is as follows
3. Generate signature
Fields participating in addrSign signature include: appId, url (webpage URL calling JavaScript API), timestamp, noncestr, accessToken
After sorting all the parameters to be signed according to the ASCII code of the field name from small to large (lexicographic order) , use the URL key-value pair format (i.e. key1=value1&key2=value2...) to concatenate it into a string string1.
It should be noted here that all parameter names during the signature process are in lowercase characters. For example, the appId string after sorting is appid;
For the signature algorithm on string1, the field names and field values ????use the original values ??and do not proceed. URL escaping. The specific signature algorithm is addrSign = SHA1(string1). The specific example of generating addrSign is given here:
appId=<span>wx17ef1eaef46752cb url</span>=http:<span>//</span><span>open.weixin.qq.com/</span> timeStamp=<span>1384841012</span><span> nonceStr</span>=<span>123456</span><span> accessToken</span>=OezXcEiiBSKSxW0eoylIeBFk1b8VbNtfWALJ5g6aMgZHaqZwK4euEskSn78Qd5pLsfQtuMdgmhajVM5QDm24W8X3tJ18kz5mhmkUcI3RoLm7qGgh1cEnCHejWQo8s5L3VvsFAdawhFxUuLmgh5FRA
i: After sorting the key-value pairs through the a process, string1 is obtained:
accesstoken=OezXcEiiBSKSxW0eoylIeBFk1b8VbNtfWALJ5g6aMgZHaqZwK4euEskSn78Qd5pLsfQtuMdgmhajVM5QDm24W8X3tJ18kz5mhmkUcI3RoLm7qGgh1cEnCHejWQo8s5L3VvsFAdawhFxUuLmgh5FRA&appid=wx17ef1eaef46752cb&noncestr=<span>123456</span>×tamp=<span>1384841012</span>&url=http:<span>//</span><span>open.weixin.qq.com/?code=CODE&state=STATE</span>
ii: After signing through process b, you can get:
addrSign=SHA1(accesstoken=<span>OezXcEiiBSKSxW0eoylIeBFk1b8VbNtfWALJ5g6aMgZHaqZwK4euEskSn78Qd5pLsfQtuMdgmhajVM5QDm24W8X3tJ18kz5mhmkUcI3RoLm7qGgh1cEnCHejWQo8s5L3VvsFAdawhFxUuLmg h5FRA</span>&appid=wx17ef1eaef46752cb&noncestr=<span>123456</span>×tamp=<span>1384841012</span>&url=http:<span>//</span><span>open.weixin.qq.com/?code=CODE&state=STATE)=ca604c740945587544a9cc25e58dd090f200e6fb</span>
The implementation code is as follows
4. Obtain the delivery address
Edit and obtain the user's delivery address editAddress interface, which is called on the front end of the web page.
Parameter list:
參數(shù) | 必填 | 說明 |
---|---|---|
appId | 是 | 公眾號(hào)appID |
scope | 是 | 填寫“jsapi_address”,獲得編輯地址權(quán)限 |
signType | 是 | 簽名方式,目前僅支持SHA1 |
addrSign | 是 | 簽名,由各參數(shù)一起參與簽名生成 |
timeStamp | 是 | 時(shí)間戳 |
nonceStr | 是 | 隨機(jī)字符串 |
The calling method is as follows
Parameter return:
返回值 | 說明 |
---|---|
err_msg | edit_address:ok獲取編輯收貨地址成功 |
edit_address:fail獲取編輯收貨地址失敗 | |
username | 收貨人姓名 |
telNumber | 收貨人電話 |
addressPostalCode | 郵編 |
proviceFirstStageName | 國(guó)標(biāo)收貨地址第一級(jí)地址 |
addressCitySecondStageName | 國(guó)標(biāo)收貨地址第二級(jí)地址 |
addressCountiesThirdStageName | 國(guó)標(biāo)收貨地址第三級(jí)地址 |
addressDetailInfo | 詳細(xì)收貨地址信息 |
nationalCode | 收貨地址國(guó)家碼 |
5. Example

Hot AI Tools

Undress AI Tool
Undress images for free

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Copying comics is undoubtedly a treasure that cannot be missed. Here you can find basketball comics in various styles, from passionate and inspiring competitive stories to relaxed and humorous daily comedy. Whether you want to relive the classics or discover new works, copying comics can meet your needs. Through the authentic online reading portal provided by copy comics, you will bid farewell to the trouble of pirated resources, enjoy a high-definition and smooth reading experience, and can support your favorite comic authors and contribute to the development of authentic comics.

Nice Comics, an immersive reading experience platform dedicated to creating for comic lovers, brings together a large number of high-quality comic resources at home and abroad. It is not only a comic reading platform, but also a community that connects comic artists and readers and shares comic culture. Through simple and intuitive interface design and powerful search functions, NES Comics allows you to easily find your favorite works and enjoy a smooth and comfortable reading experience. Say goodbye to the long waiting and tedious operations, enter the world of Nice comics immediately and start your comic journey!

Frogman Comics has become the first choice for many comic lovers with its rich and diverse comic resources and convenient and smooth online reading experience. It is like a vibrant pond, with fresh and interesting stories constantly emerging, waiting for you to discover and explore. Frog Man comics cover a variety of subjects, from passionate adventures to sweet love, from fantasy and science fiction to suspense reasoning, no matter which genre you like, you can find your favorite works here. Its simple and intuitive interface design allows you to easily get started, quickly find the comics you want to read, and immerse yourself in the exciting comic world.

Here, you can enjoy the vast ocean of comics and explore works of various themes and styles, from passionate young man comics to delicate and moving girl comics, from suspenseful and brain-burning mystery comics to relaxed and funny daily comics, there is everything, and there is always one that can touch your heartstrings. We not only have a large amount of genuine comic resources, but also constantly introduce and update the latest works to ensure that you can read your favorite comics as soon as possible.

Android mobile phone users can download and install Huobi/Huobi App through the following steps: 1. Ensure the network is stable and the storage space is sufficient; 2. Download the App through Huobi/Huobi official website, use the browser to access the official website and click the download link or scan the QR code, or search and download through third-party application stores such as AppTreasure and Huawei App Market, and you can also obtain the installation package through friends' sharing; 3. Find the downloaded .apk file, enable the "Unknown Source App" installation permission, follow the prompts to complete the installation, etc.

Yes, but there are restrictions. ① You can log in to the same account on both iPhone and Android phones, but logging in to the latest device will cause the earliest session to be offline; ② You can log in at the same time on the mobile phone and the computer desktop, but the functions are not synchronized; ③ Although using third-party tools or dual-app functions can enable logging in between two mobile phones, it is unofficially supported and may violate regulations; ④ Alternative solutions include using web version/desktop version to match the main phone, or transferring chat records through cloud backup and file tools. Some Android machines can also use "dual applications" to run two account instances.

The steps for downloading and installing the Yiou Exchange (OKX) Android client are as follows: 1. Download the official genuine installation package through the official website www.okx.com or the official QR code; 2. Find the downloaded .apk file in the mobile phone file manager and enable the "Unknown Source" installation permission; 3. Click the installation package to install, and after the installation is completed, open the APP and register or log in to the account; 4. Set up complex passwords, enable secondary verification, regularly change passwords, properly keep private keys and mnemonics, and beware of phishing websites to ensure account security.

To safely find the Ouyi official web version login portal, you must first obtain information through the official channel and cross-confirm with the browser tool for domain name verification. Users should obtain entrance information from official announcements, social media accounts and prompts in APP.
