<?php
/*
Copyright 2007 Jonathan Street jonathan@torrentialwebdev.com
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
/*
This class connects to the MSNM service and returns
all the email addresses and screen names in the contact
list of the supplied user.
This is a derivation of a more general purpose php class
available at http://flumpcakes.co.uk/php/msn-messenger.
Unlike the more general purpose class, which can handle
sending and receiving messages, this class solely connects
and the retrieves the contact list.
USAGE
=====
There are two ways of calling the class.
Verbose
-------
Calling each of the functions involved seperately and
then getting the emails from a variable in the class
include('msn_contact_grab.class.php');
$msn = new msn;
$msn->connect('username', 'password');
$msn->rx_data();
$msn->process_emails();
$returned_emails = $msn->email_output;
Quick
-----
Handling everything in just one function
include('msn_contact_grab.class.php');
$msn2 = new msn;
$returned_emails = $msn2->qGrab("username", "password");
*/
class hotmail
{
// messenger.hotmail.com is an exchange server
// using it will redirect to a server with an open slot
// using a known server ip will help connect faster
// commenting out $ssh_login will mean the url to the
// secure login server will be taken from a secure
// session. this will slow down connecting a bit.
// Note: comment out $ssh_login if you experience auth failures
var $server = 'messenger.hotmail.com';
var $port = 1863;
var $nexus = 'https://nexus.passport.com/rdr/pprdr.asp';
var $ssh_login = 'login.live.com/login2.srf';
var $debug = 0;
// curl is used for the secure login, if you don't have
// the php_curl library installed, you can use a curl binary
// instead. $use_curl needs to be set to 1 to enable this.
// set $curl to the path where curl is installed.
// curl can be downloaded here: http://curl.haxx.se/download.html
var $curl_bin = 0;
//var $curl = '/usr/local/bin/curl'; // linux
//var $curl = 'd:\curl\curl.exe'; // windows
//Used to prevent the script from hanging
var $count = 0;
//Used to store the email addresses until all have been collected
var $email_input = array();
var $email_processing = array();
var $email_output = array();
/**
*
* desc : Connect to MSN Messenger Network
*
* in : $passport = passport i.e: user@hotmail.com
* $password = password for passport
*
* out : true on success else return false
*
*/
function connect($passport, $password)
{
$this->trID = 1;
if (!$this->fp = @fsockopen($this->server, $this->port, $errno, $errstr, 2)) {
die("Could not connect to messenger service");
} else {
stream_set_timeout($this->fp, 2);
$this->_put("VER $this->trID MSNP9 CVR0\r\n");
while (! feof($this->fp))
{
$data = $this->_get();
switch ($code = substr($data, 0, 3))
{
default:
echo $this->_get_error($code);
return false;
break;
case 'VER':
$this->_put("CVR $this->trID 0x0409 win 4.10 i386 MSNMSGR 7.0.0816 MSMSGS $passport\r\n");
break;
case 'CVR':
$this->_put("USR $this->trID TWN I $passport\r\n");
break;
case 'XFR':
list(, , , $ip) = explode (' ', $data);
list($ip, $port) = explode (':', $ip);
if ($this->fp = @fsockopen($ip, $port, $errno, $errstr, 2))
{
$this->trID = 1;
$this->_put("VER $this->trID MSNP9 CVR0\r\n");
}
else
{
if (! empty($this->debug)) echo 'Unable to connect to msn server (transfer)';
return false;
}
break;
case 'USR':
if (isset($this->authed))
{
return true;
}
else
{
$this->passport = $passport;
$this->password = urlencode($password);
list(,,,, $code) = explode(' ', trim($data));
if ($auth = $this->_ssl_auth($code))
{
$this->_put("USR $this->trID TWN S $auth\r\n");
$this->authed = 1;
}
else
{
if (! empty($this->debug)) echo 'auth failed';
return false;
}
}
break;
}
}
}
}
//Collects the raw data containing the email addresses
function rx_data()
{
$this->_put("SYN $this->trID 0\r\n");
//Supplies the second MSG code which stops
//the script from hanging as it waits for
//more content
$this->_put("CHG $this->trID NLN\r\n");
$stream_info = stream_get_meta_data($this->fp);
$email_total = 100;
//the count check prevents the script hanging as it waits for more content
while ((! feof($this->fp)) && (! $stream_info['timed_out']) && ($this->count <= 1) && (count($this->email_input) < $email_total))
{
$data = $this->_get();
$stream_info = stream_get_meta_data($this->fp);
if ($data)
{
switch($code = substr($data, 0, 3))
{
default:
// uncommenting this line here would probably give a load of "error code not found" messages.
//echo $this->_get_error($code);
break;
case 'MSG':
//This prevents the script hanging as it waits for more content
$this->count++;
break;
case 'LST':
//These are the email addresses
//They need to be collected in email_input
$this->email_input[] = $data;
if ($this->debug) print("<span class='b'>" . count($this->email_input) . "</span>");
break;
case 'SYN':
$syn_explode = explode(" ", $data);
$email_total = $syn_explode[3];
break;
case 'CHL':
$bits = explode (' ', trim($data));
$return = md5($bits[2].'Q1P7W2E4J9R8U3S5');
$this->_put("QRY $this->trID msmsgs@msnmsgr.com 32\r\n$return");
break;
}
}
}
}
function getAddressbook($username, $password)
{
$returned_emails=$this->qGrab($username, $password);
foreach($returned_emails as $row){
//$totalRecords=$totalRecords+1;
//print("<tr><td style='Font-Family:verdana;Font-Size:14'>$row[1]</td><td style='Font-Family:verdana;Font-Size:14'>$row[0]</td></tr>");exit;
$result['name'][]=$row[1];
$result['email'][]=$row[0];
}
return $result;
}
//This function extracts the emails and screen names from the raw data
//collected by rx_data
function process_emails () {
//Neaten up the emails
//$regex = "|^LST\s(\S+?)\s(\S+?)\s\d+?\s\d+?$|";
foreach($this->email_input as $email_entry) {
//Seperate out the email from the name and other data
$this->email_processing[] = explode(" ", $email_entry);
}
//Get rid of the unnecessary data and clean up the name
foreach($this->email_processing as $email_entry){
$this->email_output[] = array(0 => $email_entry['1'],
没有合适的资源?快使用搜索试试~ 我知道了~
温馨提示
最近一直忙于项目上的QQ、MSN、邮箱(目前以实现163、126、gmail、sina、tom、sohu、yahoo等)通讯录地址获取;其中搜狐失效还需研究一下! 在网上找了一些,大部分都已经失效,为此我重新整理了一下;特别放出126的代码,163是比较容易抓取的;126有点变态多了一次跳转,比较麻烦; QQ邮箱联系人导出 由于腾讯查的厉害,就不奉上了! 代码浏览地址:http://www.jvones.com/blog/post-200.html
资源推荐
资源详情
资源评论
收起资源包目录
getAddressListsV1.0.zip (14个子文件)
getAddressListsV1.0
class.gmailHttp.php 2KB
class.sinahttp.php 3KB
index.php 3KB
class.126Http.php 5KB
class.yeahHttp.php 5KB
_class.sohuHttp.php 3KB
class.msnHttp.php 12KB
class.yahooHttp.php 3KB
tmp
s3_52D.tmp 0B
s2_52C.tmp 0B
s1_52B.tmp 1KB
class.163http.php 5KB
class.tomHttp.php 2KB
do.php 2KB
共 14 条
- 1
资源评论
- zsh8142897062012-11-02可能是我 玩不好 一个都不行
- xiemin0001232011-10-17好像gmail的和sina的不行,其他都不错,还有个要稍微改下,yahoo的,还可以
- 很青的青蛙2013-07-222009年前写的。 已经失效,但思路可以参考。
- mackytan2013-05-14有参考价值,需要修改后才可以使用
- bao862012-11-27都失效了,只能改
jvones
- 粉丝: 1
- 资源: 1
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功