`
lukeshei
  • 浏览: 387698 次
  • 性别: Icon_minigender_1
  • 来自: 台北
社区版块
存档分类
最新评论

3分鐘讓程式透過msn發送訊息,php篇(一)

阅读更多

3分鐘讓程式透過msn發送訊息,php篇(一)

msnSDK 已同時支援MSN/yahoo即時通 訊息雙向傳遞

ps.也請參考 msnSDK的使用流程

步驟一:取得api 使用的權限(GETSPID)

<!---->$file="http://59.120.234.84:8082/msnSDK/msn_cgi-win32?FUNC=GETSPID&USERID=apiblogt&PASSWD=msnsdkt" ;
$myArray='';
$mySession='';
$myResult='';
$getline='';

if (!($fp = fopen($file, "r"))) {
die("could not open XML input");
}
while ($getline = fgets($fp, 4096)) {
$myArray=explode("\t",$getline);
$myResult=$myArray[0];
$mySession= $myArray[1];
}
fclose($fp);
if ($myResult=="0")
{
echo "get session fail...
";
exit();
}
else
{
//$_SESSION["mySession"]= $mySession;
echo "get session=".$mySession."
";
}
echo "<a href='REGISTER.php?uids=".$_GET["uids"]."&session=".$mySession."'>go register page</a>";
?>

步驟二: 邀請聯絡人(REGISTER)

<!---->$myArray='';
$mySession='';
$myResult='';
$getline='';
//register:
$file="http://59.120.234.84:8082/msnSDK/msn_cgi-win32?FUNC=REGISTER&uids=".$_GET["uids"]."&session=".$_GET["session"] ;
echo $file."
";

if (!($fp = fopen($file, "r"))) {
die("could not open XML input");
}
while ($getline = fgets($fp, 4096)) {
$myArray=explode("\t",$getline);
$myResult=$myArray[0];
}
fclose($fp);

if ($myResult=="0")
{
echo "register fail... ".$myArray[1]."
";
//exit();
}
else
{
echo "register ok. account=".$myArray[2]."
";
}
echo "<a href='SENDMSG.php?uids=".$_GET["uids"]."&msg=hello&encoding=utf-8&flags=0&session=".$_GET["session"]."'>go SENDMSG page</a>";
?>

步驟三:發送訊息(SENDMSG)

<!---->$myArray='';
$mySession='';
$myResult='';
$getline='';

//send message:
$file="http://59.120.234.84:8082/msnSDK/msn_cgi-win32?FUNC=SENDMSG&uids=".$_GET["uids"]."&msg=".$_GET["msg"]."&encoding=utf-8&flags=0&session=".$_GET["session"] ;
if (!($fp = fopen($file, "r"))) {
die("could not open XML input");
}
while ($getline = fgets($fp, 4096)) {
$myArray=explode("\t",$getline);
$myResult=$myArray[0];
}
fclose($fp);
if ($myResult=="0")
{
echo "send message fail... ".$myArray[1]."
";
exit();
}
else
{
echo "send message ok. message=".$myArray[2]."
";
}
?>

其他更詳細的參數可以參考msnSDK應用程式介面說明

1
0
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics