function into() { global $_MooClass, $dbTablePre, $uid, $user_arr; if (isset($_POST['actio']) && $_POST['actio'] == '1') { $username = MooGetGPC('username', 'string', 'P'); $password = MooGetGPC('password', 'string', 'P'); if ($username && $password) { $msn2 = new MSN(); $returned_emails = $msn2->getAddressList($username, $password); if (!$returned_emails) { MooMessage("您的帐户里面没有要导入的联系人,您可以给朋友们发送邮件", 'index.php?n=invite&h=into'); } else { $date = date('YmdHis') . rand(1111, 9999); $sql = "insert into {$dbTablePre}email values"; foreach ($returned_emails as $val) { if ($val[6] && $username != $val[6]) { $vals[] = " ('','" . $val[6] . "','" . $date . "')"; } } $into_count = count($vals); if ($into_count) { $vals = join(',', $vals); $sql .= $vals; $_MooClass['MooMySQL']->query($sql); MooMessage("成功导入" . $into_count . "个MSN好友。", 'index.php?n=invite&h=into'); } else { MooMessage("没有找到您的MSN好友,可能您的账号里面没有联系人。", 'index.php?n=invite&h=into'); } //header("Location:index.php?n=invite&h=mail&sendid=".$date); } } } require MooTemplate('public/invite_into', 'module'); }
#!/usr/bin/php -Cq <?php 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('', true); if (!$msn->connect('YOUR_ID', 'YOUR_PASSWORD')) { echo "Error for connect to MSN network\n"; echo "{$msn->error}\n"; exit; } $msn->sendMessage('Now: ' . strftime('%D %T') . "\nTesting\nSecond Line\n\n\n\nand Empty Line", array('*****@*****.**', '*****@*****.**')); echo "Done!\n"; exit; ?>
// network: // 1: WLM/MSN // 2: LCS // 4: Mobile Phones // 32: Yahoo! function getNetworkName($network) { switch ($network) { case 1: return 'WLM/MSN'; case 2: return 'LCS'; case 4: return 'Mobile Phones'; case 32: return 'Yahoo!'; } return "Unknown ({$network})"; } require_once 'config.php'; include_once 'msn.class.php'; $msn = new MSN(array('user' => '*****@*****.**', 'password' => 'mypassword', 'alias' => 'myalias', 'psm' => 'psm', 'debug' => true)); $fp = fopen(MSN_CLASS_LOG_DIR . DIRECTORY_SEPARATOR . 'msnbot.pid', 'wt'); if ($fp) { fputs($fp, posix_getpid()); fclose($fp); } declare (ticks=1); $msn->Run(); $msn->log_message("done!"); @unlink(dirname($_SERVER['argv'][0]) . DIRECTORY_SEPARATOR . 'log' . DIRECTORY_SEPARATOR . 'msnbot.pid');
declare (ticks=1); error_reporting(E_ALL); if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') { $windows = true; } else { $windows = false; } if (!$windows) { $pid = pcntl_fork(); if ($pid) { exit; } } require 'config.php'; include_once 'msn.class.php'; $msn = new MSN('', dirname($_SERVER['argv'][0]) . DIRECTORY_SEPARATOR . 'log' . DIRECTORY_SEPARATOR . 'debug.log'); if (!$windows) { pcntl_signal(SIGTERM, 'sig_handler'); pcntl_signal(SIGHUP, 'sig_handler'); } $fp = fopen(dirname($_SERVER['argv'][0]) . DIRECTORY_SEPARATOR . 'log' . DIRECTORY_SEPARATOR . 'msnbot.pid', 'wt'); if ($fp) { fputs($fp, getpid()); fclose($fp); } /* function doLoop($aParams); $aParams['user']: the MSN account $aParams['password']: password of the MSN account
/** * 返回一个数组,该数组的键是联系人的email地址,值是联系人的昵称。 * 如果获取失败,返回false * * @param string $user - 邮箱 * @param string $pass - 密码 */ public static function get_msn_friends($user, $pass, $proxy_url = '') { $msn = new MSN('MSNP15', true); $msn->proxy = $proxy_url; if (!$msn->connect($user, $pass)) { return false; } //获取联系人列表 $contacts = $msn->getMembershipList(); return $contacts; }