Realizing micro-letter sending friends based on JS How to share the friend Circle, Weibo _javascript skills

Source: Internet
Author: User

Micro-trust browser built-in JavaScript private object Weixinjsbridge, you can send to friends, to share the circle of friends, share to microblogging and other functions.

<script> var imgurl = "Picture address";
  var linelink = "Current URL";
  var desccontent = "description";
  var sharetitle = ' title ';
  var appid = '; function Sharefriend () {weixinjsbridge.invoke (' sendappmessage ', {"AppID": AppID, "Img_url": Imgurl, "img_w Idth ":" "," Img_height ":" "," link ": Linelink," desc ": Desccontent," title ": Sharetitle}, Functi
   On (res) {//_report (' send_msg ', res.err_msg); }} function Sharetimeline () {weixinjsbridge.invoke (' sharetimeline ', {"Img_url": Imgurl, "img_width": "20
     0 "," img_height ":" "," link ": Linelink," desc ": Desccontent," title ": Sharetitle}, Function (res) {
   _report (' Timeline ', res.err_msg);
  });  function Shareweibo () {weixinjsbridge.invoke (' Shareweibo ', {' content ': desccontent, ' url ': Linelink,},
   Function (res) {//_report (' Weibo ', res.err_msg);
  });
  //The Weixinjsbridgeready event is triggered when the micro-trust built-in browser completes internal initialization. Document.addeventlistener (' WeixinjsbriDgeready ', function Onbridgeready () {//Send to Buddy Weixinjsbridge.on (' Menu:share:appmessage ', function (argv) {Sharef
   Riend ();
   });
   Share to the circle of Friends Weixinjsbridge.on (' Menu:share:timeline ', function (argv) {sharetimeline ();
   });
   Share to Weibo Weixinjsbridge.on (' Menu:share:weibo ', function (argv) {Shareweibo ();
  });
}, False); </script>

On the front page of the micro-credit public platform to add shares to the circle of friends, focus on micro-letters and other buttons

Micro-trust public platform to start supporting the front-end Web page, you may see a lot of Web pages have to share the circle of friends, attention to micro-letters and other buttons, click on them will pop up a window to let you share and attention, this is how to achieve it? Today we will explain how to add to the front page of the micro-trust public platform to share to friends circle, attention to micro-signal and other buttons.

Micro-Letter Embedded Browser

By using the MAC to remotely debug the IPhone on its own web page, we can find that a micro-letter inline browser defines a private JavaScript object: Weixinjsbridge, which can be shared into the micro-trust circle by manipulating the object's associated methods, And to judge the attention state of a micro-signal and to realize the focus on the specified micro-signal functions.

Share the Circle of friends

function Weixinsharetimeline (title,desc,link,imgurl) {
 weixinjsbridge.invoke (' Sharetimeline ', {
 "Img_url" : Imgurl,/
 /"Img_width": "640",
 //"Img_height": "640",
 "link": Link,
 "desc": Desc,
 "title": Title
 }); 

Send to a friend

function Weixinsendappmessage (title,desc,link,imgurl) {
 weixinjsbridge.invoke (' Sendappmessage ', {
 //) AppID ": AppID,
 " Img_url ": Imgurl,/
 /" Img_width ":" 640 ",
 //" Img_height ":" 640 ",
 " link ": Link,
 " Desc ":d ESC,
 title": Title
 });

Share to Tencent Weibo

function Weixinshareweibo (title,link) {
 weixinjsbridge.invoke (' Shareweibo ', {
 "content '): Title + link,
 "url": Link
 });

Focus on the specified micro-signal

function Weixinaddcontact (name) {
 Weixinjsbridge.invoke ("Addcontact", {webtype: "1", Username:name}, function (E ) {
 WeixinJSBridge.log (e.err_msg);
 E.err_msg:add_contact:added has added
 //e.err_msg:add_contact:cancel//e.err_msg:add_contact:ok add
 success
 if (e.err_msg = = ' add_contact:added ' | | | e.err_msg = = ' Add_contact:ok ') {
  //focus on success, or already concerned
 }
 })
}

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.