위챗 공중번호 개발 상용 스크립트 누적

14901 단어 위챗 공중 번호

 
공중 번호 지정:
//gh_ef65912f88f1  ID
WeixinJSBridge.invoke("addContact", {webtype: "1",username: 'gh_ef65912f88f1'}, function(e) {
            WeixinJSBridge.log(e.err_msg);
            //e.err_msg:add_contact:added  
            //e.err_msg:add_contact:cancel  
            //e.err_msg:add_contact:ok  
            if(e.err_msg == 'add_contact:added' || e.err_msg == 'add_contact:ok'){
                //
            }
        })

모멘트에 공유하기:
WeixinJSBridge.invoke('shareTimeline',{
        "img_url": "http://example.com/example.png",
        //"img_width": "640",
        //"img_height": "640",
        "link": "http://example.com",
        "desc": " ",
        "title": " "
    },function(res){
        //  res.err_msg, 
        // share_timeline:cancel  
        // share_timeline:fail  
        // share_timeline:confirm  
        WeixinJSBridge.log(res.err_msg);
         
        if(res.err_msg == 'share_timeline:confirm'){
            // 
        };
    });

 
function weixinShareTimeline(title,desc,link,imgUrl){
WeixinJSBridge.invoke(‘shareTimeline’,{
“img_url”:imgUrl,
//”img_width”:”640″,
//”img_height”:”640″,
“link”:link,
“desc”: desc,
“title”:title
});
}

친구에게 보내기:
function weixinSendAppMessage(title,desc,link,imgUrl){
WeixinJSBridge.invoke(‘sendAppMessage’,{
//”appid”:appId,
“img_url”:imgUrl,
//”img_width”:”640″,
//”img_height”:”640″,
“link”:link,
“desc”:desc,
“title”:title
});
}

텐센트 마이크로 블로그에 공유:
function weixinShareWeibo(title,link){
WeixinJSBridge.invoke(‘shareWeibo’,{
“content”:title + link,
“url”:link
});
}

지정된 위챗을 보려면 다음과 같이 하십시오.
function weixinAddContact(name){
WeixinJSBridge.invoke(“addContact”, {webtype: “1″,username: name},
function(e) {
WeixinJSBridge.log(e.err_msg);
//e.err_msg:add_contact:added  
//e.err_msg:add_contact:cancel  
//e.err_msg:add_contact:ok  
if(e.err_msg
== ‘add_contact:added’ || e.err_msg ==
‘add_contact:ok’){
//
}
})
}

 
var imgUrl = 'http://su.bdimg.com/static/superplus/img/logo_white.png';// 
var lineLink = 'http://baidu.com';// 
var descContent = "";
var shareTitle = ' ';
var appid = 'wxc9937e3a66af6dc8';  // appid
function shareFriend() {
    WeixinJSBridge.invoke('sendAppMessage',{
                            "appid": appid,
                            "img_url": imgUrl,
                            "img_width": "640",
                            "img_height": "640",
                            "link": lineLink,
                            "desc": descContent,
                            "title": shareTitle
                            }, function(res) {
                            _report('send_msg', res.err_msg);
                            })
}
function shareTimeline() {
    WeixinJSBridge.invoke('shareTimeline',{
                            "img_url": imgUrl,
                            "img_width": "640",
                            "img_height": "640",
                            "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);
                            });
}
//  WeixinJSBridgeReady 。
document.addEventListener('WeixinJSBridgeReady', function onBridgeReady() {
        //  
        WeixinJSBridge.on('menu:share:appmessage', function(argv){
            shareFriend();
            });
        //  
        WeixinJSBridge.on('menu:share:timeline', function(argv){
            shareTimeline();
            });
        //  
        WeixinJSBridge.on('menu:share:weibo', function(argv){
            shareWeibo();
            });
        }, false);

좋은 웹페이지 즐겨찾기