日期:2014-05-16 浏览次数:20525 次
1.加入微博的js,这个app_id和微游戏的app_id通用
?
<script src="http://tjs.sjs.sinajs.cn/open/api/js/wb.js?appkey=<?php echo $sns_config['app_id']; ?>" type="text/javascript" charset="utf-8"></script>
?
?
2.取得当前自己的所有粉丝
?
/**
* 新浪平台在线可互粉的玩家
*
*/
refleshOnline : function(){
var _this = this;
if(this.initData.fansIds){
this.showFans(this, this.initData.fansIds);
}else{
WB2.anyWhere(function(W){
W.parseCMD("/friendships/friends/ids.json", function(sResult, bStatus){
_this.initData.fansIds = sResult.ids;
_this.showFans(_this, sResult.ids);
},{
uid : _this.initData.playerId
},{
method: 'get'
});
});
}
},
?
3.显示互粉的好友信息
?
/**
* 显示互粉
*
* @obj _this
* @array fans_uids
*/
showFans : function(_this, fans_uids){
var _postData = {'action' : 'reflesh', 'USERNAME' : _this.initData.playerName, 'uid' : _this.initData.playerId, 'fans_ids' : fans_uids};
_this.post('ajax_get.php', _postData, function(data){
var response = JSON.parse(data);
$('#onlineusers').empty();
var index = 0;
$('#onlineusers').append("<li style=\"width: 16px; padding: 0pt 2px 2px; background: none repeat scroll 0% 0% rgb(96, 175, 5); color: rgb(255, 255, 255);\">正在线上的人</li>");
for(var uid in response['data']){
$('#onlineusers').append("<li id=\"tips_" + index + "\">"+"<a href='http://www.weibo.com/"+uid+"' target='_blank' alt='" + response['data'][uid].first_name + "'> <img border=0 src='"
+ "http://tp3.sinaimg.cn/" + uid + "/50/5608956130/0" + "' alt='" + response['data'][uid].first_name + "'/></a><br/><a href=\"http://www.weibo.com/"+uid+"\" target=\"_blank\" title='"+response['data'][uid].first_name +"'>"
+ _this.subUserName(response['data'][uid].first_name) + "</a><a href=\"javascript:;\" onclick=\"Atlantis.addFriends('"+response['data'][uid].uid+"',this)\" class=\"log_add\">+ 加关注</a></li>");
index++;
}
});
},
?
3.增加互粉接口
?
/**
* 新浪微博API:增加互粉
*
* @string uid
* @obj element
*/
addFriends : function(uid,element){
var _this = this;
WB2.anyWhere(function(W){
W.parseCMD("/friendships/create.json", function(sResult, bStatus){
_this.initData.fansIds.push(uid);
$(element).addClass('log_concerned').empty().append('<em>√</em>已关注').removeAttr("onclick");
},{
uid : uid
},{
method: 'post'
});
});
},
?
4.截取
subUserName : function(username){
if(username.length < 10)
return username;
return username.substring(0, 10) + "...";
},
?
?
?