


The content of this article is about how to call the background service (picture and text tutorial) of the WeChat applet. It has certain reference value. Friends in need can refer to it. I hope it will be helpful to you. Helps.
Written at the beginning, this article briefly records that in the WeChat applet application where the front and back ends are separated, the implementation idea of the front end accessing the background service does not involve too much technical implementation.
First, take a picture of the official website. It clearly explains what needs to be done to provide login information for each mini program user in the background service. The user gets the login credentials given by the backend and accesses the backend service.
Silent authorization and non-silent authorization
Let’s talk about these two concepts first, Silent authorization, as the name suggests, this authorization action is very important to the user. It is said that it is not perceptible, but the applet quietly did it. Therefore, information obtained without notifying the user of the authorization method is not important. However, silent authorization is an important first step because it provides the code for subsequent actions. To call silent authorization, you can use the API provided by the applet: wx.login(). Let’s talk about non-silent authorization. As the name suggests, its authorization must be obvious, and it must be approved by the user before it can be executed. API: wx.getUserInfo(), whether to use this interface depends on the actual needs of the mini program.
Get openId in the background
The applet provides an interface code2session. You can get the openId by calling this interface with the temporary login credential code we obtained through silent authorization. openId is the unique identification of the user in the current applet. Note that this step is done on the backend server. It will be clearer if we refer to the official website's documentation (backend API). It says:
The back-end API cannot be called directly through wx.request within the applet, that is, api.weixin.qq.com cannot be configured as the server domain name.
But we have questions. When we develop it ourselves, the call on the mini program is successful, which is different from what the official website says. If you encounter the same questions as me, you can take a look at this (the focus is on 4.4.2 server interface).
Generate token based on OAuth2.0
In the background, you can use SpringSecurity's OAuth2.0 tool and openId to generate the accompanying validation of the back-end data requested by the front-end. Verification information token. The author has no in-depth understanding of how to implement it specifically... After obtaining this token, the front end can store it in webStorage. Every time the background service is called, the request interceptor can be used to add the token to the config parameter. The backend can determine the identity of the user who sent the request, ensuring the security of the system.
#Summary: The above roughly describes the development ideas for the custom login state in the background of the mini program.
Reference for this article: Basic Tutorial on WeChat Mini Program Development https://www.html.cn/study/20.html
The above is the detailed content of How to call background service in WeChat applet (picture and text tutorial). For more information, please follow other related articles on the PHP Chinese website!

随着移动互联网技术和智能手机的普及,微信成为了人们生活中不可或缺的一个应用。而微信小程序则让人们可以在不需要下载安装应用的情况下,直接使用小程序来解决一些简单的需求。本文将介绍如何使用Python来开发微信小程序。一、准备工作在使用Python开发微信小程序之前,需要安装相关的Python库。这里推荐使用wxpy和itchat这两个库。wxpy是一个微信机器

小程序能用react,其使用方法:1、基于“react-reconciler”实现一个渲染器,生成一个DSL;2、创建一个小程序组件,去解析和渲染DSL;3、安装npm,并执行开发者工具中的构建npm;4、在自己的页面中引入包,再利用api即可完成开发。

实现思路x01服务端的建立首先,在服务端,使用socket进行消息的接受,每接受一个socket的请求,就开启一个新的线程来管理消息的分发与接受,同时,又存在一个handler来管理所有的线程,从而实现对聊天室的各种功能的处理x02客户端的建立客户端的建立就要比服务端简单多了,客户端的作用只是对消息的发送以及接受,以及按照特定的规则去输入特定的字符从而实现不同的功能的使用,因此,在客户端这里,只需要去使用两个线程,一个是专门用于接受消息,一个是专门用于发送消息的至于为什么不用一个呢,那是因为,只

微信小程序是一种轻量级的应用程序,可以在微信平台上运行,不需要下载安装,方便快捷。Java语言作为一种广泛应用于企业级应用开发的语言,也可以用于微信小程序的开发。在Java语言中,可以使用SpringBoot框架和第三方工具包来开发微信小程序。下面是一个简单的微信小程序开发过程。创建微信小程序首先,需要在微信公众平台上注册一个小程序。注册成功后,可以获取到

本篇文章给大家带来了关于微信小程序的相关问题,其中主要介绍了如何在小程序中用公众号模板消息,下面一起来看一下,希望对大家有帮助。

PHP与小程序的地理位置定位与地图显示地理位置定位与地图显示在现代科技中已经成为了必备的功能之一。随着移动设备的普及,人们对于定位和地图显示的需求也越来越高。在开发过程中,PHP和小程序是常见的两种技术选择。本文将为大家介绍PHP与小程序中的地理位置定位与地图显示的实现方法,并附上相应的代码示例。一、PHP中的地理位置定位在PHP中,我们可以使用第三方地理位

随着小程序的广泛应用,越来越多的开发者需要将其与后台服务器进行数据交互,其中最常见的业务场景之一就是上传文件。本文将介绍在小程序中实现文件上传的PHP后台实现方法。一、小程序中的文件上传在小程序中实现文件上传,主要依赖于小程序APIwx.uploadFile()。该API接受一个options对象作为参数,其中包含了要上传的文件路径、需要传递的其他数据以及

苏州健康码的小程序叫“苏康码”,它是苏州市疫情防控指挥部指定的通行服务码,疫情防控期间在全市范围内通用,可以作为广大民众日常出行的重要凭证,同时作为防疫人员查验的主要依据;也是省内所有来苏逗苏人员以及在苏工作学习生活,旅游或临时停留人员申报的键康申报数据为基础,结合相关数据比对后动态生成的个人电子健康凭证。


Hot AI Tools

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

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

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

MantisBT
Mantis is an easy-to-deploy web-based defect tracking tool designed to aid in product defect tracking. It requires PHP, MySQL and a web server. Check out our demo and hosting services.

Atom editor mac version download
The most popular open source editor

Dreamweaver Mac version
Visual web development tools

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

SublimeText3 English version
Recommended: Win version, supports code prompts!
