Home > Backend Development > PHP Tutorial > Discuz WeChat sharing problem solutions

Discuz WeChat sharing problem solutions

PHPz
Release: 2024-03-10 11:16:02
Original
1011 people have browsed it

Discuz WeChat sharing problem solutions

Discuz WeChat sharing problem solution

When using the Discuz forum system to develop a website, we often encounter WeChat sharing problems. Sometimes the shared content is not displayed properly. , even unable to share normally. This article will introduce how to solve common problems with Discuz WeChat sharing, and provide specific code examples for your reference.

1. Problem description

  1. When using the Discuz website, when clicking to share to WeChat, the page displays abnormally and lacks title, description and other information.
  2. After sharing to WeChat, the page cannot display the expected title, description and picture properly.
  3. When sharing on WeChat, the thumbnail is not displayed or displayed incorrectly.

2. Solution to the problem

  1. Set the website header information

Global-> Basic settings- in the Discuz backend management center > In site information, set the website header information to ensure that the page has the correct title, description and keywords. This information will be automatically recognized and displayed when shared to WeChat.

Sample code:

<meta name="description" content="网站描述">
<meta name="keywords" content="关键词">
<title>网站标题</title>
Copy after login
  1. Set WeChat sharing configuration

In the application of Discuz background management center-> WeChat-> Public account settings , fill in the information related to the WeChat official account, including the official account AppID, AppSecret, etc. Fill in the secure domain name of the website in the "JS Interface Secure Domain Name" column to ensure that WeChat can read the web page content normally.

  1. Set sharing link

In the page that needs to be shared, add relevant information shared by WeChat, including title, description and image link. The specific code examples are as follows:

<script src="http://res.wx.qq.com/open/js/jweixin-1.6.0.js"></script>
<script>
  wx.ready(function () {
    wx.onMenuShareAppMessage({
      title: '分享标题',
      desc: '分享描述',
      link: '分享链接',
      imgUrl: '分享图片链接',
      success: function() {
        // 分享成功的回调
      },
      cancel: function() {
        // 取消分享的回调
      }
    });
  });
</script>
Copy after login

In the above code, we introduced WeChat’s JS-SDK library and set the shared title, description, link and image link. Make sure that this information is obtained dynamically so that it can be displayed correctly when shared on different pages.

  1. Debugging and testing

After the setting is completed, you can open the web debugging tool to check whether the meta information of the page source code is correct, and share it in WeChat for testing , check whether the shared effect meets expectations.

3. Summary

Through the above steps and code examples, we can solve the WeChat sharing problems encountered when using Discuz. Correctly setting the website header information, WeChat sharing configuration and sharing link can ensure that the title, description and pictures can be displayed normally when sharing to WeChat. At the same time, timely debugging and testing are also key steps to solve problems and ensure the normal operation of the sharing function.

I hope the above content will be helpful to everyone who encounters WeChat sharing problems when using Discuz to develop websites, and can successfully solve related problems. I hope everyone’s website can be successfully shared on the WeChat platform and gain more traffic and attention.

The above is the detailed content of Discuz WeChat sharing problem solutions. For more information, please follow other related articles on the PHP Chinese website!

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