国产av日韩一区二区三区精品,成人性爱视频在线观看,国产,欧美,日韩,一区,www.成色av久久成人,2222eeee成人天堂

Table of Contents
1. Function introduction
After obtaining the QR code ticket, the developer can exchange the ticket with the QR code image. Please note that this interface can be called without logging in.
Still add functions based on the previous robot case, look at the code directly.
Home WeChat Applet WeChat Development WeChat public platform development to obtain personalized QR code

WeChat public platform development to obtain personalized QR code

Mar 03, 2017 am 10:06 AM
Micro-channel public platform

1. Function introduction

When promoting, we can tell the other party what our WeChat public account is, and customers can search for it and then follow it. The QR code provides us with great convenience. Just scan it and you can follow it.

If you have already followed it, jump into the conversation screen immediately. When we promote, it is no longer simple text, it can be a personalized QR code, which will definitely be very vivid.

WeChat provides good support for QR codes, and can also generate QR codes for different scenarios as needed. Below we will explain how to obtain and use QR codes.

Note: Limited to service account, and WeChat authentication is carried out, the fee is 300

微信公眾平臺開發(fā)獲取個性二維碼

## 2. Related interfaces

In order to meet the needs of user channel promotion analysis, the public platform provides an interface for generating QR codes with parameters. Using this interface, multiple QR codes with different scene values ??can be obtained. After the user scans them, the public account can receive event push.

There are currently two types of QR codes, namely temporary QR codes and permanent QR codes. The former has an expiration time, up to 1800 seconds, but can generate a larger number, while the latter has no expiration time. , the number is small (currently the parameters only support 1--1000). The two QR codes are respectively suitable for account binding, user source statistics and other scenarios.

When the user scans the QR code with scene value, the following two events may be pushed:

  1. If the user has not followed the official account, the user can follow the official account, After paying attention, WeChat will push the attention event with scene value to the developer.

  2. If the user has followed the public account, the user will automatically enter the session after scanning, and WeChat will also push the scanning event with scene value to the developer.

The process of obtaining a QR code with parameters includes two steps. First, create a QR code ticket, and then use the ticket to the specified URL to exchange for the QR code.

Create QR code ticket

Every time you create a QR code ticket, you need to provide a parameter (scene_id) set by the developer. We will introduce the temporary QR code and the permanent QR code respectively. The process of creating a QR code ticket.

Temporary QR code request instructions

http請求方式:?POST
URL:?https://api.weixin.qq.com/cgi-bin/qrcode/create?access_token=TOKENPOST數(shù)據(jù)格式:json
POST數(shù)據(jù)例子:{"expire_seconds":?1800,?"action_name":?"QR_SCENE",?"action_info":?{"scene":?{"scene_id":?123}}}

Permanent QR code request instructions

http請求方式:?POST
URL:?https://api.weixin.qq.com/cgi-bin/qrcode/create?access_token=TOKENPOST數(shù)據(jù)格式:json
POST數(shù)據(jù)例子:{"action_name":?"QR_LIMIT_SCENE",?"action_info":?{"scene":?{"scene_id":?123}}}

Parameter description

##Parameterexpire_secondsaction_nameaction_infoscene_idReturn instructions
Description
The validity time of this QR code, in seconds. The maximum number does not exceed 1800.
QR code type, QR_SCENE is temporary, QR_LIMIT_SCENE is permanent
QR code details
Scene value ID, it is a 32-bit integer when using a temporary QR code, and the maximum value when using a permanent QR code is 1000

Correct Json return result:

{"ticket":"gQG28DoAAAAAAAAAASxodHRwOi8vd2VpeGluLnFxLmNvbS9xL0FuWC1DNmZuVEhvMVp4NDNMRnNRAAIEesLvUQMECAcAAA==","expire_seconds":1800}

Parametersticketexpire_secondsWrong Json return example:
Description
The QR code ticket obtained, with this ticket you can Exchange the QR code within the valid period.
The validity time of the QR code, in seconds. The maximum number does not exceed 1800.

{"errcode":40013,"errmsg":"invalid?appid"}

Global return code description

Use the web debugging tool to debug the interface

Exchange the QR code with a ticket

After obtaining the QR code ticket, the developer can exchange the ticket with the QR code image. Please note that this interface can be called without logging in.

Request instructions

HTTP?GET請求(請使用https協(xié)議)
https://mp.weixin.qq.com/cgi-bin/showqrcode?ticket=TICKET

Return instructions

If the ticket is correct, the http return code is 200, which is a picture that can be displayed or downloaded directly.

HTTP header (example) is as follows:


Accept-Ranges:bytes
Cache-control:max-age=604800Connection:keep-alive
Content-Length:28026Content-Type:image/jpg
Date:Wed,?16?Oct?2013?06:37:10?GMT
Expires:Wed,?23?Oct?2013?14:37:10?+0800Server:nginx/1.4.1

Returned in case of error (such as illegal ticket) HTTP error code 404.

3. Specific implementation

Still add functions based on the previous robot case, look at the code directly.

///?<summary>
????///?二維碼管理者
????///?</summary>
????public?class?DimensionalCodeManager
????{
????????///?<summary>
????????///?臨時二維碼地址
????????///?</summary>
????????///?使用string.format時,報:字符串格式錯誤,因為其中有{
????????//private?const?string?TEMP_URL?=?"{\"expire_seconds\":?1800,?\"action_name\":?\"QR_SCENE\",?\"action_info\":?{\"scene\":?{\"scene_id\":?{0}}}}";
????????///?<summary>
????????///?解決辦法,將原有字符串中的一個{用兩個{代替
????????///?</summary>
????????private?const?string?TEMP_JSON_DATA?=?"{{\"expire_seconds\":?1800,?\"action_name\":?\"QR_SCENE\",?\"action_info\":?{{\"scene\":?{{\"scene_id\":?{0}}}}}}}";
????????///?<summary>
????????///?永久二維碼地址
????????///?</summary>
????????private?const?string?PERMANENT_URL?=?"{{\"action_name\":?\"QR_LIMIT_SCENE\",?\"action_info\":?{{\"scene\":?{{\"scene_id\":?{0}}}}}}}";
????????///?<summary>
????????///?獲取ticket的URL
????????///?</summary>
????????private?const?string?GET_TICKET_URL?=?"?https://api.weixin.qq.com/cgi-bin/qrcode/create?access_token={0}";
????????///?<summary>
????????///?獲取二維碼URL
????????///?</summary>
????????private?const?string?GET_CODE_URL?=?"https://mp.weixin.qq.com/cgi-bin/showqrcode?ticket={0}";
????????///?<summary>
????????///?根據(jù)場景ID獲取ticket
????????///?</summary>
????????///?<param name="sceneID">場景ID</param>
????????///?<param name="isTemp">是否是臨時二維碼</param>
????????///?<returns></returns>
????????private?static?string?GetTicket(int?sceneID,?bool?isTemp)
????????{
????????????string?result?=?null;
????????????string?data?=?string.Empty;
????????????if?(isTemp)
????????????{
????????????????data?=?string.Format(TEMP_JSON_DATA,?sceneID.ToString());
????????????}
????????????else
????????????{
????????????????if?(sceneID?>?0?&&?sceneID?<=?1000)
????????????????{
????????????????????data?=?string.Format(PERMANENT_URL,?sceneID);
????????????????}
????????????????else
????????????????{
????????????????????//scene_id不合法
????????????????????return?null;
????????????????}
????????????}

????????????string?ticketJson?=?HttpUtility.GetData(string.Format(GET_TICKET_URL,Context.AccessToken));

????????????XDocument?doc?=?XmlUtility.ParseJson(ticketJson,?"root");
????????????XElement?root?=?doc.Root;
????????????if?(root?!=?null)
????????????{
????????????????XElement?ticket?=?root.Element("ticket");
????????????????if?(ticket?!=?null)
????????????????{
????????????????????result?=?ticket.Value;
????????????????}
????????????}

????????????return?result;
????????}
????????///?<summary>
????????///?創(chuàng)建臨時二維碼
????????///?</summary>
????????///?<param name="sceneID">場景id,int類型</param>
????????///?<returns></returns>
????????public?static?string?GenerateTemp(int?sceneID)
????????{
????????????string?ticket?=?GetTicket(sceneID,true);
????????????if?(ticket?==?null)
????????????{
????????????????return?null;
????????????}

????????????return?HttpUtility.GetData(string.Format(GET_CODE_URL,?ticket));
????????}
????????///?<summary>
????????///?創(chuàng)建臨時二維碼
????????///?</summary>
????????///?<param name="sceneID">場景id,int類型</param>
????????///?<returns></returns>
????????public?static?string?GeneratePermanent(int?sceneID)
????????{
????????????string?ticket?=?GetTicket(sceneID,?false);
????????????if?(ticket?==?null)
????????????{
????????????????return?null;
????????????}

????????????return?HttpUtility.GetData(string.Format(GET_CODE_URL,?ticket));
????????}
????}

For more WeChat public platform development to obtain personalized QR codes, please pay attention to the PHP Chinese website for related articles!

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undress AI Tool

Undress AI Tool

Undress images for free

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

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

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Hot Topics

PHP Tutorial
1502
276