Created
June 15, 2015 12:42
-
-
Save lengshuiyulangcn/47091d7052ce98927b9e to your computer and use it in GitHub Desktop.
send message to weibo and facebook, not yet wechat
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<html xmlns:wb="http://open.weibo.com/wb"> | |
<head> | |
<title>js-weibo</title> | |
<script src="http://tjs.sjs.sinajs.cn/open/api/js/wb.js?appkey=your_api_key" type="text/javascript" charset="utf-8"> | |
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.6.1/jquery.min.js"></script> | |
<script> | |
WB2.anyWhere(function (W) { | |
W.widget.connectButton({ | |
id: "wb_connect_btn", | |
type: '3,2', | |
callback: { | |
login: function () { //callback after login | |
}, | |
logout: function () { //callback after logout | |
} | |
} | |
}); | |
}); | |
function post_weibo(){ | |
var message=document.getElementById("message").value; | |
WB2.anyWhere(function(W){ | |
W.parseCMD('/statuses/update.json', function(oResult, bStatus) { | |
if(bStatus) { | |
alert(oResult["text"]); | |
} | |
}, { | |
status : message | |
}, { | |
method : 'post', | |
cache_time : 30 | |
}); | |
}); | |
} | |
</script> | |
</head> | |
<script> | |
</head> | |
<script> | |
//don't ask me why it's here | |
window.fbAsyncInit = function() { | |
FB.init({ | |
appId : 'your facebook app key', | |
xfbml : true, | |
version : 'v2.3' | |
}); | |
}; | |
(function(d, s, id){ | |
var js, fjs = d.getElementsByTagName(s)[0]; | |
if (d.getElementById(id)) {return;} | |
js = d.createElement(s); js.id = id; | |
js.src = "//connect.facebook.net/en_US/sdk.js"; | |
fjs.parentNode.insertBefore(js, fjs); | |
}(document, 'script', 'facebook-jssdk')); | |
function post_facebook(){ | |
var message=document.getElementById("message").value; | |
FB.login(function(){ | |
FB.api('/me/feed', 'post', {message: message}); | |
}, {scope: 'publish_actions'}); | |
} | |
</script> | |
<body> | |
<div id="wb_connect_btn"></div> | |
<form> | |
<textarea id="message" rows="4" cols="40"></textarea> | |
</form> | |
<button type="button" id="wb_publish" onClick="post_weibo()">发布微博</button> | |
<button type="button" id="fb_publish" onClick="post_facebook()">发布facebook</button> | |
<button type="button" id="fb_publish" onClick="post_wechat()">发布微信</button> | |
<div id="status"> | |
</div> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment