首页 > 代码库 > 调用新浪微博接口,实现“分享”功能——代码实现

调用新浪微博接口,实现“分享”功能——代码实现

<!doctype html>
<html>
<head>
    <meta charset="UTF-8">
    <title>Document</title>
</head>
<body>
    <div>
        <p>点击下面的按钮可以将这段文字和图片分享到新浪微博哦!@独行冰海</p>
        <img src=‘http://t.cn/zRxMzZE‘ title=‘独行冰海‘/>
        <input type="button" class="btn" id="btn" value=‘share‘>
    </div>
</body>
<script src=‘jquery.js‘></script>
<script>
    $(#btn).click(function(){
        window.sharetitle = $(this).siblings(p).html();
        window.shareUrl = $(this).siblings(img).attr(src);
        share();
    });
    function share(){
        //d指的是window
        (function(s,d,e){try{}catch(e){}var f=http://v.t.sina.com.cn/share/share.php?,u=d.location.href,p=[url=,e(u),&title=,e(window.sharetitle),&appkey=2924220432,&pic=,e(window.shareUrl)].join(‘‘);function a(){if(!window.open([f,p].join(‘‘),mb,[toolbar=0,status=0,resizable=1,width=620,height=450,left=,(s.width-620)/2,‘,top=‘,(s.height-450)/2].join(‘‘)))u.href=[f,p].join(‘‘);};if(/Firefox/.test(navigator.userAgent)){setTimeout(a,0)}else{a()}})(screen,document,encodeURIComponent);
    }
</script>
</html>