Created
June 13, 2017 12:11
-
-
Save s1ntoneli/c803488b4fbe6c9cec49d8ac1db8158b to your computer and use it in GitHub Desktop.
微博 jssdk 登录
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
| $(document).ready(function() { | |
| // 所有的 jQuery 代码都写在这里 | |
| console.log('start here'); | |
| var access_token = ""; | |
| var app_key = "2989424062"; | |
| $('#wb_login').click(function() { | |
| console.log('clicked'); | |
| if(WB2.checkLogin()){ | |
| console.log('logged'); | |
| $('#wb_login').hide(); | |
| access_token = getAccessToken(); | |
| queryTimeline(); | |
| }else{ | |
| console.log('not logged'); | |
| WB2.login(function() { | |
| console.log('login'); | |
| access_token = getAccessToken(); | |
| }); | |
| } | |
| }); | |
| var queryTimeline = function() { | |
| WB2.anyWhere(function(W) { | |
| console.log('anyWhere'); | |
| W.parseCMD('/statuses/public_timeline.json', function(oResult, bStatus) { | |
| console.log('parseCMD'); | |
| console.log(oResult); | |
| },{ | |
| access_token: access_token | |
| },{ | |
| method: 'get', | |
| cache_time: 0 | |
| }); | |
| }); | |
| } | |
| var getAccessToken = function(){ | |
| var cookie = $.cookie("weibojs_" + app_key); | |
| return cookie.split("&")[0].split("=")[1]; | |
| }; | |
| }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment