八月 01 2009

Send MSN or Yahoo message from PHP

Published by C.K. at 9:56:29 under PHP

User View:410 | Bot View:494

標籤:, ,

http://code.google.com/p/phpmsnclass/

說明
MSN class for php, support MSNP9 (MSN 6.2) and MSNP15 (WLM 8.1), use asa bot or just send message to MSN or Yahoo (via MSN, you need Yahoo 8.1to communicate with MSN). Support OIM (offline message) if usingMSNP15.

系統需求
PHP 模組:curl, pcre, mhash, mcrypt, bcmath
至少兩組 MSN 帳號作傳訊測試

// 檢查 PHP 現有模組
#> php -m | grep -E "curl|pcre|mhash|mcrypt|bcmath"

// 安裝 PHP 模組
#> yum install php-curl php-pcre php-mhash php-mcrypt php-bcmath

範例

< ?php
$from_msnid = "msnid@from";
$from_msnpass = "password";

$to_msnid = "msnid@to";
$messages = "messages";

error_reporting(E_ALL);
include_once('msn.class.php');

// force to use MSNP9, without debug information
// $msn = new MSN('MSNP9');

// force to use MSNP9, with debug information
// $msn = new MSN('MSNP9', true);

// force to use MSNP15, without debug information
// $msn = new MSN('MSNP15');

// force to use MSNP15, with debug information
// $msn = new MSN('MSNP15', true);

// auto detect MSN protocol, without debug information
// $msn = new MSN;

// auto detect MSN protocol, with debug information
//$msn = new MSN('MSNP15', true);
$msn = new MSN('MSNP15');

if (!$msn->connect($from_msnid, $from_msnpass)) {
    echo "Error for connect to MSN network\n";
    echo "$msn->error\n";
    exit;
}

//echo "MSNID = $msnid";
$msn->sendMessage($messages,
                  array(
                    $to_msnid
                       )
                 );
echo "Done!\n";
?>
 

Bookmark and Share

No responses yet

Trackback URI | Comments RSS

Leave a Reply

(若看不到驗證碼,請重新整理網頁。)