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

Table of Contents
1. Preparation work
2. Import js
3. Inject permission verification configuration through the config interface
4. Handle successful verification through ready interface
5. Handle failed verification through error interface
js code
Home WeChat Applet WeChat Development The 'JS interface domain name' in the WeChat official account implements the sharing function

The 'JS interface domain name' in the WeChat official account implements the sharing function

Aug 08, 2018 am 09:28 AM

1. Preparation work

APPID public account id, application friend sharing interface, ip whitelist, js interface secure domain name setting (must be filed) . You must first log in to the WeChat public platform and enter the function settings of "Official Account Settings" to fill in the "JS interface domain name"

2. Import js

Note: Support the use of AMD/CMD standard loading method

<script src="http://res.wx.qq.com/open/js/jweixin-1.2.0.js"></script>

3. Inject permission verification configuration through the config interface

All pages that need to use JS-SDK must first inject configuration information, otherwise it will not be called (the same URL only needs to be called once, for changing URLs The SPA's web app can be called every time the URL changes. Currently, the Android WeChat client does not support the new H5 features of pushShate, so using pushState to implement the web app's page will cause the signature to fail. This problem will be fixed in Android 6.2)

wx.config({
  debug: true,         //開啟調(diào)試模式,調(diào)用所有的api的返回值會(huì)在客戶端alert出來,若要查看傳入的參數(shù),可以在PC端打印出來
  appId: &#39;&#39;,           //必填,公賬號(hào)的唯一標(biāo)識(shí)
  timestamp: &#39;&#39;,       //必填,生成簽名的時(shí)間戳
  nonceStr: &#39;&#39;,        //必填,生成簽名的隨機(jī)串
  signature: &#39;&#39;,       //必填,簽名
  jsApiList: [         //必填,需要使用js列表,否則無法分享成功
    &#39;onMenuShareTimeline&#39;,     //朋友圈
    &#39;onMenuShareAppMessage&#39;,   //朋友
    &#39;onMenuShareQQ&#39;,           //QQ
    &#39;onMenuShareWeibo&#39;,       //QQ空間
  ]
})

4. Handle successful verification through ready interface

wx.ready(function(){
   //config信息驗(yàn)證后會(huì)執(zhí)行ready方法,所有接口調(diào)用必須在config接口獲得結(jié)果之后,config是一個(gè)客戶端的異步操作,所以如果需要在頁面加載時(shí)就調(diào)用相關(guān)接口,則須把相關(guān)接口放在ready函數(shù)中調(diào)用來確保正確執(zhí)行。對(duì)于用戶觸發(fā)時(shí)才調(diào)用的接口,則可以直接調(diào)用,不需要放在ready函數(shù)中
});

5. Handle failed verification through error interface

wx.error({
  //config信息驗(yàn)證失敗會(huì)執(zhí)行error函數(shù),如簽名過期導(dǎo)致驗(yàn)證失敗,具體錯(cuò)誤信息可以打開config的debug模式查看,也可以在返回的res參數(shù)中查看,對(duì)于SPA可以在這里更新簽名
});

js code

var data = {
  title: &#39;&#39;,
  summary: &#39;&#39;,
  pic: &#39;&#39;,
  url: &#39;&#39;,
  success: function(){
    getWeixin() ;//用戶確認(rèn)分享后執(zhí)行的回調(diào)函數(shù)
  },
  cancel: function(){
    //用戶取消分享后執(zhí)行的回調(diào)函數(shù)
  }
}

wx.config({
  swapTitleInWX: true,
  appId: "<?php echo $weixin_package[&#39;appid&#39;];?>",
  timestamp: "<?php echo $weixin_package[&#39;timestamp&#39;];?>",
  nonceStr: "<?php echo $weixin_package[&#39;noncestr&#39;];?>",
  signature: "<?php echo $weixin_package[&#39;signature&#39;];?>",
  jsApiList: [
    &#39;onMenuShareTimeline&#39;,
    &#39;onMenuShareAppMessage&#39;,
    &#39;onMenuShareQQ&#39;,
    &#39;onMenuShareWeibo&#39;,
   ]
})

wx.ready(function () {
  wx.onMenuShareTimeline(data);
  wx.onMenuShareAppMessage(data);
  wx.onMenuShareQQ(data)
  wx.onMenuShareWeibo(data)
})

Notes:

  1. title, it is recommended to be within 14 characters

  2. Picture size: 300*300 pixels; picture format: size does not exceed 10kB, GIF is not supported Format; will take the first qualified picture in the body of the current page

  3. Briefly interpret the title, it is recommended to be within 20 words

  4. ## link:'', //Share link, change the link domain name or path must be consistent with the public account JS security domain name corresponding to the current page

2. QQ sharing

QQ The shared icon and title are identified through the tags in the head, involving itemprop, an attribute of h5 microdata,

<meta itemprop="name" content="標(biāo)題"/>
<meta itemprop="description" name="description" content="描述"/>
<meta itemprop="image" content="縮列圖地址"/>
Related recommendations:

WeChat public account custom sharing content Realize

WeChat public account authorization settings, WeChat public authorization

The above is the detailed content of The 'JS interface domain name' in the WeChat official account implements the sharing function. For more information, please follow other related articles on the PHP Chinese website!

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)