【X5.0.3+】新版本将 支持自带微信分享以及统一的微信方法(给插件开发者用)
微信统一方法给「微信生态功能」复用的统一入口(避免插件之间重复刷新 access_token 互相挤掉)。
微信的 client_credential(cgi-bin/token)是【同一 AppID 全局唯一、刷新即作废旧 token】的凭证。若各功能、插件各自独立去刷新,会互相把对方的 token 打掉,导致间歇性失效。因此本方法提供【唯一的、带缓存与并发锁】的令牌入口。
统一的token获取机制
php
▼ 展开
取得分享/模板消息/自定义菜单等后端 API 共用的 access_token,内部按 appid 隔离缓存、带文件锁防止并发刷新冲突。
统一的ticket获取机制
php
▼ 展开
取得 JS-SDK 用的 jsapi_ticket(基于上面的 token,自动复用)。
注意:本文件缓存的是「公众平台后端 API 凭证(cgi-bin/token)」,与核心 account_wechat 用于「网页授权登录(sns/oauth2/access_token)」的用户级 token 是【两种不同类型】,请勿混用,也无需复用。
统一的微信分享
在后台配置并开启微信分享功能后,页面后端使用
php
▼ 展开
定义分享的数据,页面自动处理数据,未定义时,本身Discuz也会智能识别页面信息,并使用后台兜底的配置形成分享数据。 沙发 摇摇椅 前排支持 支持 支持
.ce-block { margin-bottom: 20px;}.ce-block__content,.ce-toolbar__content { /* max-width:calc(100% - 50px) */ margin-left: auto; margin-right: auto;}.ce-paragraph { line-height: 1.6em; outline: none; text-indent: 2em; font-size: 16px;}.ce-paragraph--right { text-align: right;}.ce-paragraph--center { text-align: center;}.ce-paragraph--left { text-align: left;}.ce-paragraph--justify { text-align: justify;}.ce-paragraph-text-indent { text-align: justify;}.ce-paragraph:empty::before{content: attr(data-placeholder);color: #707684;font-weight: normal;opacity: 0;}/** Show placeholder at the first paragraph if Editor is empty */.codex-editor--empty .ce-block:first-child .ce-paragraph:empty::before {opacity: 1;}.codex-editor--toolbox-opened .ce-block:first-child .ce-paragraph:empty::before,.codex-editor--empty .ce-block:first-child .ce-paragraph:empty:focus::before {opacity: 0;}.ce-paragraph p:first-of-type{ margin-top: 0;}.ce-paragraph p:last-of-type{ margin-bottom: 0;}.svg-icon { width: 1em; height: 1em;}.svg-icon path,.svg-icon polygon,.svg-icon rect { fill: #4691f6;}.svg-icon circle { stroke: #4691f6; stroke-width: 1;}.inline-code {background: rgba(250, 239, 240, 0.78);color: #b44437;padding: 3px 4px;border-radius: 5px;margin: 0 1px;font-family: inherit;font-size: 0.86em;font-weight: 500;letter-spacing: 0.3px;} 现在的版本可以用了吗 很方便了
.ce-block { margin-bottom: 20px;}.ce-block__content,.ce-toolbar__content { /* max-width:calc(100% - 50px) */ margin-left: auto; margin-right: auto;}.ce-paragraph { line-height: 1.6em; outline: none; text-indent: 2em; font-size: 16px;}.ce-paragraph--right { text-align: right;}.ce-paragraph--center { text-align: center;}.ce-paragraph--left { text-align: left;}.ce-paragraph--justify { text-align: justify;}.ce-paragraph-text-indent { text-align: justify;}.ce-paragraph:empty::before{content: attr(data-placeholder);color: #707684;font-weight: normal;opacity: 0;}/** Show placeholder at the first paragraph if Editor is empty */.codex-editor--empty .ce-block:first-child .ce-paragraph:empty::before {opacity: 1;}.codex-editor--toolbox-opened .ce-block:first-child .ce-paragraph:empty::before,.codex-editor--empty .ce-block:first-child .ce-paragraph:empty:focus::before {opacity: 0;}.ce-paragraph p:first-of-type{ margin-top: 0;}.ce-paragraph p:last-of-type{ margin-bottom: 0;}.svg-icon { width: 1em; height: 1em;}.svg-icon path,.svg-icon polygon,.svg-icon rect { fill: #4691f6;}.svg-icon circle { stroke: #4691f6; stroke-width: 1;}.inline-code {background: rgba(250, 239, 240, 0.78);color: #b44437;padding: 3px 4px;border-radius: 5px;margin: 0 1px;font-family: inherit;font-size: 0.86em;font-weight: 500;letter-spacing: 0.3px;}
页:
[1]