代码很简单,大家看下面一串代码
http://follow.v.t.qq.com/index.php?c=follow&a=quick&name=csharpcckan&style=3&f=1
只要把csharpcckan换成你的微博用户名就行了。
在浏览器里访问一下效果如下
在线测试:http://www.cckan.net/thread-461-1-1.html
咱们一来看看它返回的HTML代码吧
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<title>腾讯微博-与其在别处仰望 不如在这里并肩</title>
<meta http-equiv="Content-type" content="text/html; charset=utf-8" />
<meta name="Keywords" content="" />
<meta name="Description" content="" />
<script type="text/javascript" src="http://mat1.gtimg.com/app/vt/js/follow/jquery.js"></script>
<style>
#content{font: 12px/2 Tahoma,Arial;text-align: left;}
.bg{background:url("http://mat1.gtimg.com/app/vt/images/follow/quickfollowbgnew.gif?v=1215");}
.toleft{float:left;}
.cfont{font-size:10px;font-family:"微软雅黑";}
</style>
<link href="http://mat1.gtimg.com/app/vt/css/follow/quickfollownewstyle3.css?v=1215" type=text/css rel=stylesheet>
</head>
<body style="margin: 0; background: transparent; overflow:hidden;">
<div id="content">
<input type="hidden" id="name" value="csharpcckan">
<div class="main" style="overflow:hidden">
<div class="bg account"><a href="#" id="followbtn">cckan</a><span class="bg cfont cfollowleft"> </span><span class="bg cfont cfollow">347</span><span class="bg cfont cfollowright"> </span></div>
</div>
</div>
<script>
var s = 3;
var unlogin=false;$('#followbtn').click(function(){
if(unlogin)
{
var returnvalue=window.showModalDialog("http://follow.v.t.qq.com/index.php?c=follow&a=login", "", "dialogWidth=500px;dialogHeight=300px");
if(returnvalue==undefined){
return;
}
}
postFollow();
});
function changeEvent()
{
$('#followbtn').unbind('click');
$('.main').css('cursor', 'pointer').click(function(){ window.open('http://t.qq.com/csharpcckan')});
}
function getcookie(name) {
var cookie_start = document.cookie.indexOf(name);
var cookie_end = document.cookie.indexOf(";", cookie_start);
return cookie_start == -1 ? '' : unescape(document.cookie.substring(cookie_start + name.length + 1, (cookie_end > cookie_start ? cookie_end : document.cookie.length)));
}
function postFollow()
{
$.ajax({
type: "POST",
url: "http://follow.v.t.qq.com/index.php?c=follow&a=listen",
data: "name="+$('#name').val()+"&hash="+getcookie('__hash__')+"&time="+new Date().getTime(),
success: function(msg){
var d=eval('('+(msg||"{}")+')');
if (d.ret == 0) {
if (false) {
} else if (s==1 ) {
changeEvent();
var followed = $('<span class="bg action followed"> </span>').css("overflow","hidden");
$('#followbtn').replaceWith(followed);
} else if( s==2) {
changeEvent();
$('#followbtn').replaceWith('已收听');
} else if( s==3) {
changeEvent();
alert("收听成功");
} else if( s==4) {
changeEvent();
$('#followbtn').replaceWith('<span class="bg toleft noaction"></span>');
} else if( s==5) {
changeEvent();
$('#followbtn').replaceWith('<span class="bg toleft noaction"></span>');
} else {
changeEvent();
$('#followbtn').html('已收听');
$('#followbtn').unbind('click');
}
} else {
if(d.errcode==6)
{
window.open('http://t.qq.com/'+$('#name').val());
}else{
alert(d.msg);
}
}
}
});
}
</script>
</body>
</html>
好了接下来我们如果想加到自己的网站就直接引用就行,相显示就直接使用IFrame,如果想取值就直接GET或者POST吧。
测试网站:http://www.cckan.net