php WeChat public account js-sdk development application_php example

PHP中文网
Release: 2023-03-03 07:48:01
Original
1254 people have browsed it

To test the interface function of js, I used BAE server not SAE server. The SAE server cannot write files and there will be problems with the test.
What is js-sdk? Let me first demonstrate the specific function of the js-sdk interface.

I randomly opened a push article on WeChat as shown below:

php WeChat public account js-sdk development application_php example


Click on the first article



The above is our connected article. If we send this article to a friend , the display effect is as follows:

php WeChat public account js-sdk development application_php example


Share to Moments and let’s take a look at the effect:

php WeChat public account js-sdk development application_php example


Why is the interface effect displayed in the official account, send to friends, and send to Moments when it is also an article link? no the same. The display effect of the official account is because the WeChat official account calls the WeChat message interface when pushing, and the latter two are because the page calls the SDK interface related to js-sdk.
Send to friends calls the js interface to obtain the "Share to Friends" button click status and customize the sharing content interface.
Send to Moments calls the js interface to obtain the click status of the "Share to Moments" button and customize the sharing content interface.


Let’s implement the steps to call the js-sdk interface:


Step 1: Enter the "Function Settings" of the "Official Account Settings" on the WeChat public platform and fill in the "JS Interface Security Domain Name".


As shown below:

php WeChat public account js-sdk development application_php example


Only pages placed under this domain name can call the js interface.

Step 2:
http://demo.open.weixin.qq.com/jssdk/sample.zip Connect to this address to download, open the php folder inside, and you will find 4 php files

php WeChat public account js-sdk development application_php example

The first three php files are configuration files, do not touch them. sample.php is the connection page we open in WeChat. In this page we write our page code. I used this file for testing, and the code in it is different from the original version.

GetSignPackage();//获取配置参数。
?>
Copy after login

我靠猪八戒你好唐生
Copy after login

🎜
Related labels:
source:php.cn
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template