Yahoo Messenger API
Đây là class login vào yahoo, set status và gửi tin nhắn cho 1 nick. Tôi sưu tầm trên mạng mà giờ chẳng biết bài viết gốc nó nằm mô rồi. Hix!
<?
// Class 'Yahoo Messenger API' v1.0
// details : send pm to any yahoo messenger IDs via PHP
// (c) Hadi Fanaee , Iran , Mashhad , Kasbarg Information Technology .
// Released under the terms of the GNU Public License
// Website : www.php45.com
// Email : info@php45.com
class Ymess {
//-------------------------------------PACKETS----------------------------------------------------
Function Packet1($MyWAPHost)
{
$StrPck = "GET / HTTP/1.1\n";
$StrPck.="Referer: /\n";
$StrPck.="Accept-Language: en-us\n";
$StrPck.="User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 2.0.50727)\n";
$StrPck.="Host: $MyWAPHost\n\n";
return $StrPck;
}
Function Packet2($MySID,$MyWAPHost,$MyIntl,$MyCookie)
{
$StrPck = "GET /p/messenger?$MySID HTTP/1.1\n";
$StrPck.="Referer: /\n";
$StrPck.="Accept-Language: en-us\n";
$StrPck.="User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 2.0.50727)\n";
$StrPck.="Host: $MyWAPHost\n" ;
$StrPck.="Cookie: $MyIntl$MyCookie\n\n";
return $StrPck;
}
Function Packet3($MyWAPHost,$MyIntl,$MyCookie)
{
$StrPck = "GET /p/messenger HTTP/1.1\n";
$StrPck.="Referer: /\n";
$StrPck.="Accept-Language: en-us\n" ;
$StrPck.="User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 2.0.50727)\n" ;
$StrPck.="Host: $MyWAPHost\n" ;
$StrPck.="Cookie: $MyIntl$MyCookie\n\n" ;
return $StrPck;
}
Function Packet4($MyWID,$MyWAPHost,$MyCookie)
{
$StrPck = "GET /p/messenger/welcome?r=$MyWID HTTP/1.1\n" ;
$StrPck.="Referer: /\n";
$StrPck.="Accept-Language: en-us\n" ;
$StrPck.="User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 2.0.50727)\n" ;
$StrPck.="Host: $MyWAPHost\n" ;
$StrPck.="Cookie: $MyCookie\n\n" ;
return $StrPck;
}
Function Packet5($MyCID,$MyWID,$MySID,$MyWAPHost,$MyIntl,$MyCookie)
{
$StrPck = "POST /p/messenger?c=$MyCID&r=$MyWID&ySiD=$MySID HTTP/1.1\n" ;
$StrPck.="Referer: /\n" ;
$StrPck.="Accept-Language: en-us\n" ;
$StrPck.="User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 2.0.50727)\n" ;
$StrPck.="Host: $MyWAPHost\n" ;
$StrPck.="Cookie: $MyIntl$MyCookie\n\n" ;
return $StrPck;
}
Function Packet6($MyWID,$MyWAPHost,$MyIntl,$MyCookie)
{
$StrPck = "GET /p/logout?r=$MyWID HTTP/1.1\n" ;
$StrPck.="Referer: /p/messenger?r=$MyWID\n" ;
$StrPck.="Accept-Language: en-us\n" ;
$StrPck.="User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 2.0.50727)\n" ;
$StrPck.="Host: $MyWAPHost\n" ;
$StrPck.="Cookie: $MyIntl$MyCookie\n\n" ;
return $StrPck;
}
Function Packet7($MyMsg,$MyVictim,$MyCID,$MyWID,$MyIntl,$MyWAPHost,$MyCookie)
{
$mess= substr($MyMsg, 0, 940);
$Pck = "message=$mess&wmlfix=Send" ;
$lenmess=strlen($Pck);
$StrPck = "POST /p/messenger/chat/$MyVictim/sendIm?c=$MyCID&r=$MyWID HTTP/1.1\n" ;
$StrPck.="Referer: /p/messenger/chat/$MyVictim?c=$MyCID&r=$MyWID\n" ;
$StrPck.="Accept-Language: en-us\n" ;
$StrPck.="Accept: image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, application/x-shockwave-flash, */*\n" ;
$StrPck.="Content-Type: application/x-www-form-urlencoded\n" ;
$StrPck.="User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 2.0.50727)\n" ;
$StrPck.="Host: $MyWAPHost\n" ;
$StrPck.="Content-Length: $lenmess\n" ;
$StrPck.="Connection: Keep-Alive\n" ;
$StrPck.="Cache-Control: no-cache\n" ;
$StrPck.="Cookie: $MyIntl$MyCookie\n\n$Pck" ;
return $StrPck;
}
Function Packet8($MyYID,$MyPw,$MyCookieHost)
{
$StrPck="";
$StrPck.="GET /config/login?login=$MyYID&passwd=$MyPw HTTP/1.1\n";
$StrPck.="Referer: /config/login?\n" ;
$StrPck.="Accept-Language: en-us\n" ;
$StrPck.="User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 2.0.50727)\n" ;
$StrPck.="Host:$MyCookieHost\n" ;
$StrPck.="Accept: text/html\n\n" ;
return $StrPck;
}
Function Packet9()
{
$Pck = "user=" & $MyVictim & "&buddyGroup=Friends&message=" & substr($MyMsg, 1, 940) & "&wmlfix=Add" ;
$StrPck = "POST /p/messenger/contacts/addComplete?c=" & $MyCID & "&r=" & $MyWID & " HTTP/1.1" & "\n" ;
$StrPck.="Referer: /p/messenger/contacts/add?c=" & $MyCID & "&r=" & $MyWID & "\n" ;
$StrPck.="Accept-Language: en-us" & "\n" ;
$StrPck.="Accept: image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, application/x-shockwave-flash, */*" & "\n" ;
$StrPck.="Content-Type: application/x-www-form-urlencoded" & "\n" ;
$StrPck.="User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 2.0.50727)" & "\n" ;
$StrPck.="Host: " & $MyWAPHost & "\n" ;
$StrPck.="Content-Length: " & strlen($Pck) & "\n" ;
$StrPck.="Connection: Keep-Alive" & "\n" ;
$StrPck.="Cache-Control: no-cache" & "\n" ;
$StrPck.="Cookie: " & $MyIntl & $MyCookie & "\n" & "\n" & $Pck ;
return $StrPck;
}
Function Packet12($MyCID,$MyWID,$MyIntl,$MyWAPHost,$MyCookie,$MySID)
{
//http://wap.yahoo.com/p/messenger/contacts/recent?g=Friends&c=Xn8TUwVHetB&r=1620424127&ySiD=oCChSJj.2f9bJBbg7Vy9
$StrPck = "GET /p/messenger/contacts/recent?g=Friend&c=$MyCID&r=$MyWID&ySiD=$MySID HTTP/1.1\n" ;
$StrPck.="Referer: /\n" ;
$StrPck.="Accept-Language: en-us\n" ;
$StrPck.="User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 2.0.50727)\n" ;
$StrPck.="Host: $MyWAPHost\n" ;
$StrPck.="Cookie: $MyIntl$MyCookie\n\n" ;
return $StrPck;
}
Function Packet10()
{
$StrPck = "GET /p/messenger/contacts/deny?yid=" & $MyVictim & "&c=" & $MyCID & "&r=" & $MyWID & " HTTP/1.1" & "\n" ;
$StrPck.="Referer: /p/messenger/notify?yid=" & $MyVictim & "&c=" & $MyCID & "&r=" & $MyWID & "\n" ;
$StrPck.="Accept-Language: en-us" & "\n" ;
$StrPck.="User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 2.0.50727)" & "\n" ;
$StrPck.="Host: " & $MyWAPHost & "\n" ;
$StrPck.="Cookie: " & $MyIntl & $MyCookie & "\n" & "\n" ;
return $StrPck;
}
Function Packet11($MyMsg,$MyCID,$MyWID,$MyIntl,$MyWAPHost,$MyCookie)
{
$mess= substr($MyMsg, 0, 250);
$Pck = "message=$mess&wmlfix=Submit" ;
$lenmess=strlen($Pck);
$StrPck = "POST /p/messenger/prefs/status/submit?c=$MyCID&r=$MyWID HTTP/1.1\n" ;
$StrPck.="Referer: /p/messenger/prefs/status?c=$MyCID&r=$MyWID\n" ;
$StrPck.="Accept-Language: en-us\n" ;
$StrPck.="Accept: image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, application/x-shockwave-flash, */*\n" ;
$StrPck.="Content-Type: application/x-www-form-urlencoded\n" ;
$StrPck.="User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 2.0.50727)\n" ;
$StrPck.="Host: $MyWAPHost\n" ;
$StrPck.="Content-Length: $lenmess\n" ;
$StrPck.="Connection: Keep-Alive\n" ;
$StrPck.="Cache-Control: no-cache\n" ;
$StrPck.="Cookie: $MyIntl$MyCookie\n\n$Pck" ;
return $StrPck;
}
//-------------------------------------PACKETS----------------------------------------------------
//--------------------------------------------------------------------------------------
function Connect($pServer,$hPort){
$hStream = fsockopen($pServer, $hPort);
if(!$hStream){$IsConnect=0;echo "Cannot connect to $pServer at port $hPort"; exit;}
$IsConnect=1;
return array($IsConnect,$hStream);
}
//--------------------------------------------------------------------------------------
function Disconnect($hStream){
fclose($hStream);
}
//--------------------------------------------------------------------------------------
function GetDataArrival ($hStream){
// $hResult = '';
while(!feof($hStream)) {
// receive the results of the request
$hResulttmp.= fgets($hStream);
}
$hResult=html_entity_decode($hResulttmp);
return $hResult;
}
//--------------------------------------------------------------------------------------
function SendData($hStream,$Data){
fputs($hStream, $Data);
}
//--------------------------------------------------------------------------------------
function LoginWap ($myID,$myPass,$CookieHost,$wapHost,$Status,$VictimID,$Message){
$logged=0;
list($Connected5,$stream5) = $this->Connect($CookieHost, 80);
if ($Connected5=1){
$this->SendData($stream5 , $this->Packet8($myID,$myPass,$CookieHost));
$res5 = $this->GetDataArrival($stream5);
if ($res5 <> ''){
//GET COOKIE
$cookie1 = $this->GetCode("Y=v=",";",$res5);
$cookie2 = $this->GetCode("T=z=",";",$res5);
//if($cookie1="" OR $cookie2=""){echo "CONNECT FAILED! SERVER IS BUSY OR INVALID ID/PASS. TRY AGAIN LATER.";}
$cookie = "Y=v=$cookie1; T=z=$cookie2";
}
}
//[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[
list($Connected,$stream) = $this->Connect($wapHost, 80);
if ($Connected=1){
$this->SendData($stream , $this->Packet1($wapHost));
$res = $this->GetDataArrival($stream);
if ($res <> ''){
//GET SID AND INTL
$sid = $this->GetCode("ySiD=",'"',$res);
$intltmp = $this->GetCode("B=",";",$res);
$intl= "B=$intltmp;" ;
}
}
//[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[
list($Connected1,$stream1) = $this->Connect($wapHost, 80);
if ($Connected1=1){
$this->SendData($stream1 , $this->Packet2($sid,$wapHost,$intl,$cookie));
$res1 = $this->GetDataArrival($stream1);
if ($res1 <> ''){
//ENTER SID AND INTL
}
}
//[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[
list($Connected2,$stream2) = $this->Connect($wapHost, 80);
if ($Connected2=1){
$this->SendData($stream2 , $this->Packet3($wapHost,$intl,$cookie));
$res2 = $this->GetDataArrival($stream2);
if ($res2 <> ''){
//GET WID
$widtmp = $this->GetCode("welcome?r=","C",$res2);
$wid = substr($widtmp,0,strlen($widtmp)-2);
// $Dat5 = explode("welcome?r=",$res2);
//$Dat6 = explode($res2,$Dat5[1]);
//$wid = $Dat6[0];
}
}
//[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[
list($Connected3,$stream3) = $this->Connect($wapHost, 80);
if ($Connected3=1){
$this->SendData($stream3 , $this->Packet4($wid,$wapHost,$cookie));
$res3 = $this->GetDataArrival($stream3);
if ($res3 <> ''){
//GET CID
$cid = $this->GetCode("?c=","&r=",$res3);
}
}
//[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[
list($Connected4,$stream4) = $this->Connect($wapHost, 80);
if ($Connected4=1){
$this->SendData($stream4 , $this->Packet5($cid,$wid,$sid,$wapHost,$intl,$cookie));
$res4 = $this->GetDataArrival($stream4);
if ($res4 <> ''){
//FINNALLY CONNECT
//echo "COOKIE:$cookie ______________SID:$sid ______________WID:$wid ______________CID:$cid ______________INTL:$intl" ;
$logged=1;
}
}
//[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[
$num = rand(0,10000);
sleep(1);
$this->SetStatus($Status,$cid,$wid,$intl,$wapHost,$cookie);
//$this->LogoutWap($wid, $wapHost,$intl ,$cookie);
//sleep(1);
//$mess1 = $this->Test($cid,$wid,$intl,$wapHost,$cookie,$sid);
//sleep(1);
$this->SendMessage($Message,$VictimID,$cid,$wid,$intl,$wapHost,$cookie);
//sleep(1);
$logged=1;
//sleep(1); exit;
return array($cid,$wid,$sid,$intl,$cookie,$wapHost,$logged);
}
//--------------------------------------------------------------------------------------
function LogoutWap($MyWID,$MyWAPHost,$MyIntl,$MyCookie){
list($Connected,$stream) = $this->Connect($MyWAPHost, 80);
if ($Connected=1){
$this->SendData($stream , $this->Packet6($MyWID,$MyWAPHost,$MyIntl,$MyCookie));
$res = $this->GetDataArrival($stream);
if ($res <> ''){
//LOGOUT
echo $this->Packet6($MyWID,$MyWAPHost,$MyIntl,$MyCookie);
}
}
}
//--------------------------------------------------------------------------------------
function SendMessage($MyMsg,$MyVictim,$MyCID,$MyWID,$MyIntl,$MyWAPHost,$MyCookie){
list($Connected,$stream) = $this->Connect($MyWAPHost, 80);
if ($Connected=1){
$this->SendData($stream , $this->Packet7($MyMsg,$MyVictim,$MyCID,$MyWID,$MyIntl,$MyWAPHost,$MyCookie));
$res = $this->GetDataArrival($stream);
if ($res <> ''){
//LOGOUT
//echo $this->Packet6($MyWID,$MyWAPHost,$MyIntl,$MyCookie);
}
}
}
//--------------------------------------------------------------------------------------
/*function Test($MyCID,$MyWID,$MyIntl,$MyWAPHost,$MyCookie,$MySID){
list($Connected,$stream) = $this->Connect($MyWAPHost, 80);
if ($Connected=1){
$this->SendData($stream , $this->Packet12($MyCID,$MyWID,$MyIntl,$MyWAPHost,$MyCookie,$MySID));
$res = $this->GetDataArrival($stream);
if ($res <> ''){
//LOGOUT
echo $res;
}
}
return $res;
} */
//--------------------------------------------------------------------------------------
function SetStatus($MyMess,$MyCID,$MyWID,$MyIntl,$MyWAPHost,$MyCookie){
list($Connected,$stream) = $this->Connect($MyWAPHost, 80);
if ($Connected=1){
$this->SendData($stream , $this->Packet11($MyMess,$MyCID,$MyWID,$MyIntl,$MyWAPHost,$MyCookie));
$res = $this->GetDataArrival($stream);
if ($res <> ''){
//
}
}
//return 0;
}
//--------------------------------------------------------------------------------------
function GetCode($start,$end,$str){
$x1=strpos($str,$start);
if($x1){
$x2=strpos($str,$end , $x1+1);
$getbet=substr($str,$x1+strlen($start),$x2-$x1-strlen($start));
}else{
$getbet="";
}
return $getbet;
}
}
?>
Lưu file lại với tên là yim.php
Tạo 1 file để test với nội dung:
<?php
include("yim.php");
$ym=new Ymess();
$mess = ":))";
list($MyCid,$MyWid,$MySid,$MyIntl,$MyCookie,$MyWapHost,$logged)=$ym->LoginWap("Nick","Pass",'login.yahoo.com','us.m.yahoo.com',"Status","Victim","Nội dung tin nhắn");
?>
Popularity: 30% [?]
sử dụng như thế nào hả bạn, mình mù về món này nhưng cũng mún bít thêm 1 tý