Look at the effect

Small program to support SMS jump small program, can be said to open a huge traffic entrance.

Effect process analysis

  1. From text messages to web pages
  2. From web pages to applets

So there are two points involved

  1. Send a text message
  2. Web page jump

Analysis of implementation steps

  1. You have to have a page, you can jump to the applet
  2. Then send a text message containing the address

Specific implementation Steps

1. There should be a web page to jump to the applet

Start with static web hosting

To create a cloud development project, click the “Cloud Development” button at the top left

Click the static page to open.

Then click “Download resource Pack”, unzip it and we’ll see

The first is the cloud function and the second is the web page to jump to. First let’s edit the jump page

Open the file and edit the following 6 places (search “replace” to quickly locate the changes) :



After adding the parameters, upload the deployment to your static managed file directory

At this point, the web is done, and the next step is to deploy the cloud function.

Copy the contents of index.js in the public folder below the Cloudfunctions folder to the index.js folder of your new cloudfunction, and then replace the path of your small program.

The main purpose of this cloud function is that static web pages will call it to generate the URL Scheme to jump to. The following is the code area where a web page calls this function

Here the page display and page jump only the last step, set the cloud function permissions.

The first step, click Settings, slide to the point to turn on the “not logged in user permission switch”.



Step 2: Click the cloud function, modify the permission and copy the code below to cover.

Custom security rule configuration:

{ "*": { "invoke": "auth ! = null" }, "public": { "invoke": true } }Copy the code

2. Send a short message containing the address

Create a sendSms to the cloud function and copy the following code:

const cloud = require('wx-server-sdk') cloud.init() exports.main = async (event, context) => { try { const result = await cloud.openapi.cloudbase.sendSms({ env: 'online-12345678910', // Replace environment ID content: 'Cloud development supports SMS jump applet ',// replace SMS copy path: '/index.html',// replace webpage path phoneNumberList: [ "+8612345678910" ] }) return result } catch (err) { return err } }Copy the code

Replace the above three contents.

  1. Environment ID, which can be found in Settings
  2. Text message content, this is your own custom
  3. Page path, in static page hosting click upload to the page to view replication

After the modification is complete, deploy it.

You’re done

Small program can call the cloud function to send SMS, SMS will come with the web address, click can jump to the small program.

Wechat search “Chen Yu Ming”, attention after the reply “small program” can get my small program development tutorial