How to add a link to the WeChat public account on the website

Source: Internet
Author: User

How to add a Public Account link to a website

Here, the free spread of Public Accounts refers to spreading your public accounts to friends and friends. After a friend clicks in, he can follow your public accounts in the shortest path! If your article is pushed through the background of the public platform, you will find that the corresponding public account nickname can be clicked, And you can directly open the public account information page. Let's take a look at its source code:

HTML code:

Baidufe

Javascript code:

Function viewProfile (){

If (typeof WeixinJSBridge! = "Undefined" & WeixinJSBridge. invoke ){

WeixinJSBridge. invoke ('profile ',{

'Username': 'gh _ dd4b2c2ada8b ',/* original ID of your public account */

'Scene': '57'

});

}

}

You may be glad to think that this code has taken effect!

In fact, this Code takes effect only in the mp.weixin.qq.com domain in the iOS environment!

Of course, you can doubt that, next we can make a simple modification to the above Javascript code to see what information will be obtained in callback:

Function viewProfile (){

If (typeof WeixinJSBridge! = "Undefined" & WeixinJSBridge. invoke ){

WeixinJSBridge. invoke ('profile ',{

'Username': 'gh _ dd4b2c2ada8b ',/* original ID of your public account */

'Scene': '57'

}, Function (resp ){

Alert (resp. err_msg);/* here, We output err_msg */

});

}

}

We deploy the code to our own web server, such as: http://www.baidufe.com/demo/wxid_test.html, then open this link with a built-in browser, click the tag defined in HTML, call the viewProfile method, the "not_allow" error message is displayed!

How can this problem be solved? Is there really no way to easily spread public accounts on your own pages?

In fact, we can look around it like this:

1. Push the simplest text message through the background of the public platform, which generates an independent page. on this page, you can click the nickname to open the public account information page. For example, this Demo independent page

2. Add a link on our own page to point to the independent page generated above

The independent page is similar:

Of course, all discussed above are for the iPhone version. Indeed, the WebView on iOS is much more restrictive than the WebView on Android.

Next, let's take a look at how to promote the public account on Android & WP.

In fact, it is very simple (I wrote it in my previous Blog), it is done by a link:

Click here to add the Baidufe public account

Above, you can spread the public account freely on your page!

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.