Let WeChat share unregistered domain name URLs with introduction and pictures

Starting in 2016, if you want to share a link with friends or Moments, if you do not use the official API, the picture and introduction will not be displayed, which makes the sharing experience a lot worse. And if you want to use the official API, you not only need a certified WeChat ID, but also a domain name bound to the background for registration. There are two troubles here: one is that the domain name needs to be registered, and the other is that only three can be bound.

Starting from January 1, 2018, domain name registration requires real-name authentication. All overseas domain name providers do not have this function, which means that you must transfer the domain name back to the domestic operator before you can register it. Overseas domain names basically cannot be registered. Today I came up with a solution to allow WeChat sharing to display introductions and pictures without changing the existing domain name and system.

First you need:

  1. A certified WeChat ID for sharing API
  2. A registered domain name, just buy one and register it
  3. Use the API to run the sharing program on a website with a registered domain name

The basic principle is actually very simple, that is, use curl to obtain the website under the registered domain name, and then share it. When users check, they will see the original website under the registered domain name, but when performing operations, they will return to the original domain name. When sharing on WeChat, the domain name called by the WeChat API is the registered domain name. I posted the code directly and wrote some notes without explaining it. Since the website is GBK, the GBK conversion is added, but it is actually not necessary.

GetSignPackage(); //get url and set gbk(optional) header('Content-type: text/html; charset=GBK'); $url=$_GET['url']; //curl page $ch = curl_init(); $timeout = 10; curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $timeout); $data = curl_exec($ch); curl_close($ch); // get title, desc, keyword $doc = new DOMDocument(); @$doc->loadHTML($data); $nodes = $doc->getElementsByTagName('title'); $title = $nodes->item(0)->nodeValue; $metas = $doc->getElementsByTagName('meta'); for ($i = 0; $i < $metas->length; $i++) { $meta = $metas->item($i); if($meta->getAttribute('name') == 'description') $description = $meta->getAttribute('content'); if($meta->getAttribute('name') == 'keywords') $keywords = $meta->getAttribute('content'); } print_r($data); ?> 

If you don’t know how to use WeChat JDK, I will write a simple tutorial later.

In addition, the original shared website needs to regenerate each QR code. For example, if your registered domain name is sbicp.com, then the QR code shared by your original website needs to be: http://sbicp.com/share.php?url=oldurl.com/path/

As for how to generate a QR code, there are quite a few online. I used this one:https://www.jianshu.com/p/dfefe14d9f2f

It works for personal testing, please leave a message if you have any questions.

This siteOriginal articleAll follow "Attribution-NonCommercial-ShareAlike 4.0 License (CC BY-NC-SA 4.0)". Please keep the following tags for sharing and interpretation:

Original author:Jake Tao,source:"Let WeChat share unregistered domain name URLs with introduction and pictures"

224
0 10 224

Further reading

Leave a Reply

Log inCan comment later

Comment list (10)

  • Story
    Story 2021-01-07 02:48

    I’m not very good at using WeChat JDK. When you have time, can you write a simple tutorial?

    • avatar of heaven
      Heaven 2021-01-07 09:53

      @Story WeChat has official documentation, you can check it out: https://developers.weixin.qq.com/doc/

  • Story
    Story 2020-12-22 03:22

    Is this invalid now?

  • Kicked Tea
    Kicked Tea 2018-07-17 00:24

    Master, is there any way to share without WeChat authentication number?

    • avatar of heaven
      Heaven 2018-07-17 07:04

      @ Being kicked small teaNo, it is only possible that the domain name has not been registered. . .

    • anonymous
      anonymous 2020-04-11 23:22

      @Jake TaoI have an unregistered domain name and I want to share it with pictures. Can you help me get it? Pay

    • avatar of heaven
      Heaven 2020-04-11 23:58

      @anonymousYou need to have at least one registered domain name for redirection. It is recommended to register one first

  • Kicked Tea
    Kicked Tea 2018-07-16 21:52

    I have a domain name registered in China, but when sharing a WeChat link, I can only include pictures and titles. The introduction is a URL link. Is there any way to change the introduction to the head content of the article? This way the user experience is much better.

    • avatar of heaven
      Heaven 2018-07-16 21:57

      @ Being kicked small teaRefer to the code above:

      window.share_config = {
      'share': {
      'imgUrl': imgurl,
      'desc' : desc,
      'title' : title,
      'link': window.location.href,
      success: function (res) {
      }
      }
      };

Share this page
Back to top