Im having problem in importing hotmail contacts from hotmail in php it simple give the erorr message : Error code not found
Please tell me what im doing wrong. I want this to be working.
Im using thew msn_contact_grab.class.php
and iam calling as :
<?php
include('msn_contact_grab.class.php');
$msn2 = new msn;
$returned_emails = $msn2->qGrab("just_4_love01#hotmail.com", "xxxxxxx");
?>
msn_contact_grab.class.php is as follows:
<?php
class msn
{
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;
var $curl_bin = 0;
var $curl = 'c:/wamp/www/hotmail/curl/curl'; // linux
//var $curl = 'c:\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;
}
}
}
}
//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'],
1 => urldecode($email_entry[2]));
}
//var_dump($this->email_processing);
//var_dump($this->email_output);
}
//This is a quick way of calling all the seperate functions
//needed to grab the contact list
function qGrab ($username, $password) {
//Connect to the MSNM service
$this->connect($username, $password);
//Get data
$this->rx_data();
//Process emails
$this->process_emails();
//send the email array
return $this->email_output;
}
/*====================================*\
Various private functions
\*====================================*/
function _ssl_auth($auth_string)
{
if (empty($this->ssh_login))
{
if ($this->curl_bin)
{
exec("$this->curl -m 60 -LkI $this->nexus", $header);
$header = implode($header, null);
}
else
{
$ch = curl_init($this->nexus);
curl_setopt($ch, CURLOPT_HEADER, 1);
curl_setopt($ch, CURLOPT_NOBODY, 1);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
// curl_setopt($ch, CURLOPT_TIMEOUT, 2);
$header = curl_exec($ch);
curl_close($ch);
}
preg_match ('/DALogin=(.*?),/', $header, $out);
if (isset($out[1]))
{
$slogin = $out[1];
}
else
{
return false;
}
}
else
{
$slogin = $this->ssh_login;
}
if ($this->curl_bin)
{
$header1 = '"Authorization: Passport1.4 OrgVerb=GET,OrgURL=http%3A%2F%2Fmessenger%2Emsn%2Ecom,sign-in='.$this->passport.',pwd='.$this->password.','.$auth_string.'"';
exec("$this->curl -m 60 -LkI -H $header1 https://$slogin", $auth_string);
$header = null;
foreach ($auth_string as $key => $value)
{
if (strstr($value, 'Unauthorized'))
{
echo 'Unauthorised';
return false;
}
elseif (strstr($value, 'Authentication-Info'))
{
$header = $value;
}
}
}
else
{
$ch = curl_init('https://'.$slogin);
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
'Authorization: Passport1.4 OrgVerb=GET,OrgURL=http%3A%2F%2Fmessenger%2Emsn%2Ecom,sign-in='.$this->passport.',pwd='.$this->password.','.$auth_string,
'Host: login.passport.com'
));
curl_setopt($ch, CURLOPT_HEADER, 1);
curl_setopt($ch, CURLOPT_NOBODY, 1);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
// curl_setopt($ch, CURLOPT_TIMEOUT, 2);
$header = curl_exec($ch);
curl_close($ch);
}
preg_match ("/from-PP='(.*?)'/", $header, $out);
return (isset($out[1])) ? $out[1] : false;
}
function _get()
{
if ($data = #fgets($this->fp, 4096))
{
if ($this->debug) echo "<div class=\"r\"><<< $data</div>\n";
return $data;
}
else
{
return false;
}
}
function _put($data)
{
fwrite($this->fp, $data);
$this->trID++;
if ($this->debug) echo "<div class=\"g\">>>> $data</div>";
}
function _get_error($code)
{
switch ($code)
{
case 201:
return 'Error: 201 Invalid parameter';
break;
case 217:
return 'Error: 217 Principal not on-line';
break;
case 500:
return 'Error: 500 Internal server error';
break;
case 540:
return 'Error: 540 Challenge response failed';
break;
case 601:
return 'Error: 601 Server is unavailable';
break;
case 710:
return 'Error: 710 Bad CVR parameters sent';
break;
case 713:
return 'Error: 713 Calling too rapidly';
break;
case 731:
return 'Error: 731 Not expected';
break;
case 800:
return 'Error: 800 Changing too rapidly';
break;
case 910:
case 921:
return 'Error: 910/921 Server too busy';
break;
case 911:
return 'Error: 911 Authentication failed';
break;
case 923:
return 'Error: 923 Kids Passport without parental consent';
break;
case 928:
return 'Error: 928 Bad ticket';
break;
default:
return 'Error code '.$code.' not found';
break;
}
}
}
?>
(moving this from a comment to an answer)
It's probably not that you are doing anything wrong, it's probably just that this class is fishy. The $curl = 'c:/...'; // linux line doesn't instill a lot of confidence. This also seems to be reverse-engineering the messenger protocol, which is a very fragile thing to do.
There seems to be an official API, which you should be using instead: http://dev.live.com/contacts/
Related
Every time I run the code below, I get a WSOD. Not sure what I'm doing wrong with this code. Nothing gets logged and I've verified my php.ini configurations are well set to display all errors. Any help on this would be appreciated.
// MAIN BIDDING FUNCTION MAIN BIDDING FUNCTION
// this function performs no checking on the input variables
$username = '1*****';
$password = '******';
$item = '*******';
$bid = '***.**';
// $link - itemlink with referral, can leave empty i.e. ''
function place_bid($username, $password, $item, $bid, $link) {
$cookies = dirname(__FILE__).'/cookies.txt';
//set success as default false
$success = false;
$bid_success = false;
$curl = curl_init();
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($curl, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.4) Gecko/20030624 Netscape/7.1 (ax)');
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($curl, CURLOPT_REFERER, $link);
curl_setopt($curl, CURLOPT_COOKIEFILE, $cookies);
curl_setopt($curl, CURLOPT_COOKIEJAR, $cookies);
//query the sign-out page
//curl_setopt($curl, CURLOPT_URL, "https://signin.ebay.com/ws/eBayISAPI.dll?SignIn&lgout=1");
//$ret = curl_exec ($curl);
//query the referal link page
if ($link) {
curl_setopt($curl, CURLOPT_URL, $link);
$ret = curl_exec ($curl);
}
//IMPORTANT
//query the sign-in page to set the cookies
curl_setopt($curl, CURLOPT_URL, 'https://signin.ebay.com/aw-cgi/eBayISAPI.dll?SignIn&campid=5337161990&customid=7');
$ret = curl_exec ($curl);
$data = [];
$numbers = [];
if (preg_match('%(<form name="SignInForm".*?<\/form)%im', $ret, $regs)) {
$dom = new DOMDocument;
$dom-loadHTML($regs[0]);
$nodes = $dom-getElementsByTagName('input');
foreach($nodes as $node) {
$name = $node-getAttribute('name');
$value = $node-getAttribute('value');
//$size = $node-getAttribute('size');
$type = $node-getAttribute('type');
$data[$name] = $value;
if (is_numeric($name)) {
if ($type == 'text') {
$data[$name] = $username;
}
if ($type == 'password') {
$data[$name] = $password;
}
}
}
}
unset($data['']);
$data_str = http_build_query($data);
//sign-in
curl_setopt($curl, CURLOPT_URL, "https://signin.ebay.com/ws/eBayISAPI.dll?co_partnerId=2&siteid=0&UsingSSL=1");
curl_setopt($curl, CURLOPT_CUSTOMREQUEST, 'POST');
curl_setopt($curl, CURLOPT_POSTFIELDS, $data_str);
$ret = curl_exec ($curl);
if(curl_errno($curl)){
ebaylog('Curl error: ' . curl_error($curl));
}
if (!$ret) {
$ret = curl_exec ($curl);
if(curl_errno($curl)){
ebaylog('Curl error: ' . curl_error($curl));
}
if (!$ret) {
$ret = curl_exec ($curl);
if(curl_errno($curl)){
ebaylog('Curl error: ' . curl_error($curl));
}
}
}
curl_setopt($curl, CURLOPT_URL, 'https://www.ebay.com/myb/WatchList');
$ret = curl_exec ($curl);
//test_write($ret);
if(curl_errno($curl)){
ebaylog('Curl error: ' . curl_error($curl));
}
if (!$ret) {
$ret = curl_exec ($curl);
if(curl_errno($curl)){
ebaylog('Curl error: ' . curl_error($curl));
}
if (!$ret) {
$ret = curl_exec ($curl);
if(curl_errno($curl)){
ebaylog('Curl error: ' . curl_error($curl));
}
}
}
//if (strpos($ret, '"loggedIn":true') === FALSE) {
if ((strpos($ret, "userid={$username}") === FALSE) && (strpos($ret, "usr/{$username}") === FALSE)) {
if (preg_match('%<b class="altTitle"(.*)</b%', $ret, $regs)) {
$err = $regs[1];
ebaylog("\"{$err}\"");
if (strpos($err, 'The alerts below') === 0) {
ebaylog("{$item}: 'The alerts below' found, successful");
//set it to succes
}
} else {
ebaylog("{$item}: Failed signing in");
if (preg_match('%<font face=".*?" size="3"<b(.*?)</b</font%', $ret, $regs)) {
$err = $regs[1];
ebaylog("\"{$err}\"");
}
//test_write($ret);
goto end;
}
} else {
ebaylog("{$item}: Success signing in");
}
//place the inital bid
curl_setopt($curl, CURLOPT_URL, "https://offer.ebay.com/ws/eBayISAPI.dll?MakeBid&item={$item}&maxbid={$bid}&campid=5337161990&customid=7");
$ret = curl_exec ($curl);
if(curl_errno($curl)){
ebaylog('Curl error: ' . curl_error($curl));
}
if (!$ret) {
$ret = curl_exec ($curl);
}
if (preg_match_all('/(?:value="([-0-9a-zA-Z]*)" *)?name="stok"(?: *value="([-0-9a-zA-Z]*)")?/', $ret, $regs)) {
$stok = $regs[1][0];
} else {
//Failed to get 'stok' value
//try and determine why
if (preg_match('%<div class="statusDiv"(.*?)</div%', $ret, $regs)) {
$err = $regs[1];
ebaylog("'{$err}'");
//if string starts with "Enter US $0.41 or more"
if (stripos($err, 'Enter') === 0) {
ebaylog("{$item}: 'Enter' found, aborting");
//set it to success
$success = true;
} else if (stripos($err, 'To enter a') === 0) {
ebaylog("{$item}: 'To enter a' found, aborting");
//set it to success
$success = true;
} else if (stripos($err, 'Transaction Blocked') === 0) {
ebaylog("{$item}: 'Transaction Blocked' found, aborting");
//set it to success
$success = true;
}
} else if (preg_match('%"\d*" - Invalid Item</div%', $subject)) {
ebaylog("{$item}: 'Invalid Item' found, aborting");
test_write($ret);
//set it to success
$success = true;
} else if (preg_match('%<div class="subTlt"<ul class="errList"<li(.*?)</li</ul</div%', $subject)) {
ebaylog("{$item}: 'no longer available' found, aborting");
test_write($ret);
//set it to success
$success = true;
} else if (preg_match('%id="w\d-\d-_msg".*?(.*?)</span%', $ret, $regs)) {
ebaylog("'{$regs[1]}'");
} else if (preg_match('%<div\s+class\s*=\s*"(?:errRed|errBlk|errTitle|statusDiv)"\s*(.*?)</div%i', $ret, $regs)) {
ebaylog("'{$regs[1]}'");
} else {
//don't know why so log the page
ebaylog("{$item}: Failed to get 'stok' value");
test_write($ret);
}
goto end;
}
if (preg_match_all('/(?:value="([-0-9a-zA-Z]*)" *)?name="uiid"(?: *value="([-0-9a-zA-Z]*)")?/', $ret, $regs)) {
$uiid = $regs[1][0];
} else {
ebaylog("{$item}: Failed to get 'uiid' value");
goto end;
}
if ($stok && $uiid) {
ebaylog("{$item}: Success placing initial bid");
} else {
ebaylog("{$item}: Failed placing initial bid");
goto end;
}
//confirm the bid
curl_setopt($curl, CURLOPT_URL, "https://offer.ebay.com/ws/eBayISAPI.dll?MfcISAPICommand=MakeBid&maxbid={$bid}&quant=1&mode=1&stok={$stok}&uiid={$uiid}&co_partnerid=2&user={$username}&fb=0&item={$item}&campid=5337161990&customid=7");
$ret = curl_exec ($curl);
if(curl_errno($curl)){
ebaylog('Curl error: ' . curl_error($curl));
}
if (!$ret) {
$ret = curl_exec ($curl);
}
//perform a number of tests to determine if the bid was a success
$bid_success = true;
if (stripos($ret, "you're the first bidder") === FALSE) {
if (stripos($ret, "you're the high bidder and currently in the lead") === FALSE) {
if (stripos($ret, "you're currently the highest bidder") === FALSE) {
$bid_success = false;
ebaylog("{$item}: Failed placing final bid");
//try and determine why
if (preg_match('%<div\s+class\s*=\s* (?:errRed|errBlk|errTitle|statusDiv|title)"\s*(.*?)</div%i', $ret, $regs)) {
$err = $regs[1];
ebaylog("'{$err}'");
if (stripos($err, 'Enter') === 0) {
ebaylog("{$item}: 'Enter' found, aborting");
//set it to success
$bid_success = true;
} else if (stripos($err, "You've just been outbid") === 0) {
ebaylog("{$item}: 'You've just been outbid' found, aborting");
//set it to success
$bid_success = true;
} else if (stripos($err, "You're currently the high bidder,") === 0) {
ebaylog("{$item}: 'You're currently the high bidder, but the reserve hasn't been met.' found, aborting");
//set it to success
$bid_success = true;
}
} else {
//we don't know why it failed so write the data
test_write($ret);
}
}
}
}
if ($bid_success) {
ebaylog("{$item}: Success placing final bid");
$success = true;
}
end:
//close the curl session
curl_close ($curl);
if ($success) {
ebaylog("{$item}: Success: {$username}");
} else {
ebaylog("{$item}: Failure: {$username}");
}
return $success;
}
?
I know this question has been asked multiple times, however looking through all the solutions, none of them have seemed to work for me.
I've been using the IPN Simulator on the PayPal website to integrate Subscriptions into my website, yet the IPN is always returning invalid.
I've tried multiple ways to get this working, but this is my current method:
<?php
class IpnListener {
public $use_curl = true;
public $force_ssl_v3 = false;
public $follow_location = false;
public $use_ssl = true;
public $use_sandbox = false;
public $timeout = 30;
private $post_data = array();
private $post_uri = '';
private $response_status = '';
private $response = '';
const PAYPAL_HOST = 'www.paypal.com';
const SANDBOX_HOST = 'www.sandbox.paypal.com';
protected function curlPost($encoded_data) {
if ($this->use_ssl) {
$uri = 'https://'.$this->getPaypalHost().'/cgi-bin/webscr';
$this->post_uri = $uri;
} else {
$uri = 'http://'.$this->getPaypalHost().'/cgi-bin/webscr';
$this->post_uri = $uri;
}
$ch = curl_init();
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, true);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2);
curl_setopt($ch, CURLOPT_CAINFO, dirname(__FILE__)."/cacert.pem");
curl_setopt($ch, CURLOPT_URL, $uri);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $encoded_data);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, $this->follow_location);
curl_setopt($ch, CURLOPT_TIMEOUT, $this->timeout);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HEADER, true);
if ($this->force_ssl_v3) {
curl_setopt($ch, CURLOPT_SSLVERSION, 3);
} else {
curl_setopt($ch, CURLOPT_SSLVERSION, 4);
}
$this->response = curl_exec($ch);
$this->response_status = strval(curl_getinfo($ch, CURLINFO_HTTP_CODE));
if ($this->response === false || $this->response_status == '0') {
$errno = curl_errno($ch);
$errstr = curl_error($ch);
throw new Exception("cURL error: [$errno] $errstr");
}
}
protected function fsockPost($encoded_data) {
if ($this->use_ssl) {
$uri = 'ssl://'.$this->getPaypalHost();
$port = '443';
$this->post_uri = $uri.'/cgi-bin/webscr';
} else {
$uri = $this->getPaypalHost(); // no "http://" in call to fsockopen()
$port = '80';
$this->post_uri = 'http://'.$uri.'/cgi-bin/webscr';
}
$fp = fsockopen($uri, $port, $errno, $errstr, $this->timeout);
if (!$fp) {
// fsockopen error
throw new Exception("fsockopen error: [$errno] $errstr");
}
$header = "POST /cgi-bin/webscr HTTP/1.1\r\n";
$header .= "Host: ".$this->getPaypalHost()."\r\n";
$header .= "Content-Type: application/x-www-form-urlencoded\r\n";
$header .= "Content-Length: ".strlen($encoded_data)."\r\n";
$header .= "Connection: Close\r\n\r\n";
fputs($fp, $header.$encoded_data."\r\n\r\n");
while(!feof($fp)) {
if (empty($this->response)) {
// extract HTTP status from first line
$this->response .= $status = fgets($fp, 1024);
$this->response_status = trim(substr($status, 9, 4));
} else {
$this->response .= fgets($fp, 1024);
}
}
fclose($fp);
}
private function getPaypalHost() {
if ($this->use_sandbox) return self::SANDBOX_HOST;
else return self::PAYPAL_HOST;
}
public function getPostUri() {
return $this->post_uri;
}
public function getResponse() {
return $this->response;
}
public function getResponseStatus() {
return $this->response_status;
}
public function getTextReport() {
$r = '';
// date and POST url
for ($i=0; $i<80; $i++) { $r .= '-'; }
$r .= "\n[".date('m/d/Y g:i A').'] - '.$this->getPostUri();
if ($this->use_curl) $r .= " (curl)\n";
else $r .= " (fsockopen)\n";
// HTTP Response
for ($i=0; $i<80; $i++) { $r .= '-'; }
$r .= "\n{$this->getResponse()}\n";
// POST vars
for ($i=0; $i<80; $i++) { $r .= '-'; }
$r .= "\n";
foreach ($this->post_data as $key => $value) {
$r .= str_pad($key, 25)."$value\n";
}
$r .= "\n\n";
return $r;
}
public function processIpn($post_data=null) {
$encoded_data = 'cmd=_notify-validate';
if ($post_data === null) {
// use raw POST data
if (!empty($_POST)) {
$this->post_data = $_POST;
$encoded_data .= '&'.file_get_contents('php://input');
} else {
throw new Exception("No POST data found.");
}
} else {
// use provided data array
$this->post_data = $post_data;
foreach ($this->post_data as $key => $value) {
$encoded_data .= "&$key=".urlencode($value);
}
}
if ($this->use_curl) $this->curlPost($encoded_data);
else $this->fsockPost($encoded_data);
if (strpos($this->response_status, '200') === false) {
throw new Exception("Invalid response status: ".$this->response_status);
}
if (strpos($this->response, "VERIFIED") !== false) {
return true;
} elseif (strpos($this->response, "INVALID") !== false) {
return false;
} else {
throw new Exception("Unexpected response from PayPal.");
}
}
public function requirePostMethod() {
// require POST requests
if ($_SERVER['REQUEST_METHOD'] && $_SERVER['REQUEST_METHOD'] != 'POST') {
header('Allow: POST', true, 405);
throw new Exception("Invalid HTTP request method.");
}
}
Then the Payment.php class, which is where PayPal sends the request too.
/*The Database Connection Code Is Here*/
include('ipnlistener.php');
$listener = new IpnListener();
$listener->use_sandbox = true;
//$listener->use_curl = false;
try {
$verified = $listener->processIpn();
} catch (Exception $e) {
file_put_contents("paymentdev.php", $e->getMessage()." ".date("H:i"));
//file_put_contents("paymentdev.php", "fudge");
exit(0);
}
if ($verified) {
file_put_contents("paymentdev.php", "test");
$data = $_POST;
$user_id = json_decode($data['custom'])->user_id;
$subscription = ($data['mc_gross_1'] == '49.95') ? 2 : 1;
$txn_id = $data['txn_id'];
$user_id = $user_id;
$paypal_id = $data['subsc_id'];
$subscription = $subscription;
$expires = date('Y-m-d H:i:s', strtotime('+1 Month'));
$sql = "SELECT * FROM payments WHERE user_id=$user_id";
$payment = $mysqli->query($sql);
if(isset($payment) && $payment->num_rows > 0)
{
$sql = "DELETE FROM payments WHERE user_id=$user_id";
$delete = $mysqli->query($sql);
}
$sql = "INSERT INTO payments (txn_id, user_id, paypal_id, expires, subscription) VALUES ('$txn_id', $user_id, '$paypal_id', '$expires', $subscription)";
$insertpayment = $mysqli->query($sql);
file_put_contents("paymentdev.php", $mysqli->error);
} else {
file_put_contents("paymentdev.php", "Transaction not verified ".date("H:i")."<br>".$listener->getTextReport());
echo "Error: Transaction not verified";
}
Thanks in advance for all your help guys!
Turns out the code I was using was just fine, I updated the server a bit more just to ensure it was using the latest cURL and open ssl, but even so the sandbox would always return INVALID. I tried the live version with subscriptions priced at $0.01 and the payment went through, was valid and my database was updated
Must just be something weird with the IPN simulator/sandbox
I am using Google’s Calculator API. I have to pass dynamic values to the google url as below:
$url = 'http://www.google.com/ig/calculator?hl=en&q=' . urlEncode($amount . $currency . '=?' . $exchangeIn);
But I am getting the following exception from the google.
Warning: file_get_contents(http://www.google.com/ig/calculator?hl=en&q=13,000,000pkr=?cad) [function.file-get-contents]: failed to open stream: HTTP request failed! HTTP/1.0 503 Service Unavailable in /home/..../public_html/config/config.php on line 48
My function for this is as:
function exchangeRate($amount, $currency, $exchangeIn) {
$url = 'http://www.google.com/ig/calculator?hl=en&q=' . urlEncode($amount . $currency . '=?' . $exchangeIn);
$data = file_get_contents($url);
if(!$data) {
throw new Exception('Could not connect');
}
$json = new Services_JSON(SERVICES_JSON_LOOSE_TYPE);
$array = $json->decode($data);
if(!$array) {
throw new Exception('Could not parse the JSON');
}
if($array['error']) {
throw new Exception('Google reported an error: ' . $array['error']);
}
return number_format($array['rhs']);
}
echo exchangeRate('9,200,000', 'pkr', 'cad')
Can somebody what is wrong with my code or something wrong with this google api ?
Thanks
I also created currency calculator using Google’s Calculator API like that. Below is my code.
Usage:
simply use your own URL like: yourdomain.com/file.php?from=USD&to=EUR&q=10
The PHP Script:
<?php
session_start();
if(isSet($_GET['from']) && isSet($_GET['to']) && isSet($_GET['q'])) {
$from = preg_replace('/[^A-Z]/','',$_GET['from']);
$to = preg_replace('/[^A-Z]/','',$_GET['to']);
$q = preg_replace('/[^0-9\.]/','',$_GET['q']);
echo currency($from,$to,$q);
}
function currency($from_Currency,$to_Currency,$amount) {
$cookieName = md5("$from_Currency|$to_Currency|$amount");
if(isSet($_COOKIE["$cookieName"])) {
echo $_COOKIE["$cookieName"];
}
else {
$amount = urlencode($amount);
$from_Currency = urlencode($from_Currency);
$to_Currency = urlencode($to_Currency);
$url = "http://www.google.com/ig/calculator?hl=en&q=$amount$from_Currency=?$to_Currency";
$ch = curl_init();
$timeout = 0;
curl_setopt ($ch, CURLOPT_URL, $url);
curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_USERAGENT , $_SERVER['HTTP_USER_AGENT']);
curl_setopt ($ch, CURLOPT_CONNECTTIMEOUT, $timeout);
$rawdata = curl_exec($ch);
curl_close($ch);
$data = html_entity_decode($rawdata);
$data = str_replace(array('lhs','rhs','error','icc',': '),array('"lhs"','"rhs"','"error"','"icc"',':'),$data);
$row = json_decode($data,true);
if(preg_match('/million/',$row['rhs'])) {
$x = 1000000;
}
else if(preg_match('/billion/',$row['rhs'])) {
$x = 1000000000;
}
else {
$x = 1;
}
$result = preg_replace('/[^0-9\.]/','',$row['rhs']);
$kurs = $result * $x;
if($row['icc'] == 'true') {
setcookie("$cookieName", number_format($kurs,2), time()+3600);
return number_format($kurs,2);
}
else {
return "Not available";
}
}
}
?>
i need some advise on this one, im having trouble figuring out the array that comes from google contacts, im already extracting the email from an example i found online, but now i need to extract the name of the contact and the phone number, i am seeing this information in the array doing a print_r() but dont know how to get it.
This is are my files:
gmail.php (this one prints all the emails, here i need also name and phone)
include_once 'GmailOath.php';
$oauth =new GmailOath($consumer_key, $consumer_secret, $argarray, $debug, $callback);
$getcontact_access=new GmailGetContacts();
$request_token=$oauth->rfc3986_decode($_GET['oauth_token']);
$request_token_secret=$oauth->rfc3986_decode($_SESSION['oauth_token_secret']);
$oauth_verifier= $oauth->rfc3986_decode($_GET['oauth_verifier']);
$contact_access = $getcontact_access->get_access_token($oauth,$request_token, $request_token_secret,$oauth_verifier, false, true, true);
$access_token=$oauth->rfc3986_decode($contact_access['oauth_token']);
$access_token_secret=$oauth->rfc3986_decode($contact_access['oauth_token_secret']);
$contacts= $getcontact_access->GetContacts($oauth, $access_token, $access_token_secret, false, true,$emails_count);
foreach($contacts as $k => $a)
{
$final = end($contacts[$k]);
foreach($final as $email)
{
echo 'email: ' . $email["address"] .'<br>';
}
}
GmailOath.php
<?php
class GmailOath {
public $oauth_consumer_key;
public $oauth_consumer_secret;
public $progname;
public $debug;
public $callback;
function __construct($consumer_key, $consumer_secret, $argarray, $debug, $callback) {
$this->oauth_consumer_key = $consumer_key;
$this->oauth_consumer_secret = $consumer_secret;
$this->progname = $argarray;
$this->debug = $debug; // Set to 1 for verbose debugging output
$this->callback = $callback;
}
////////////////// global.php open//////////////
function logit($msg, $preamble=true) {
// date_default_timezone_set('America/Los_Angeles');
$now = date(DateTime::ISO8601, time());
error_log(($preamble ? "+++${now}:" : '') . $msg);
}
function do_get($url, $port=80, $headers=NULL) {
$retarr = array(); // Return value
$curl_opts = array(CURLOPT_URL => $url,
CURLOPT_PORT => $port,
CURLOPT_POST => false,
CURLOPT_SSL_VERIFYHOST => false,
CURLOPT_SSL_VERIFYPEER => false,
CURLOPT_RETURNTRANSFER => true);
if ($headers) {
$curl_opts[CURLOPT_HTTPHEADER] = $headers;
}
$response = $this->do_curl($curl_opts);
if (!empty($response)) {
$retarr = $response;
}
return $retarr;
}
function do_post($url, $postbody, $port=80, $headers=NULL) {
$retarr = array(); // Return value
$curl_opts = array(CURLOPT_URL => $url,
CURLOPT_PORT => $port,
CURLOPT_POST => true,
CURLOPT_SSL_VERIFYHOST => false,
CURLOPT_SSL_VERIFYPEER => false,
CURLOPT_POSTFIELDS => $postbody,
CURLOPT_RETURNTRANSFER => true);
if ($headers) {
$curl_opts[CURLOPT_HTTPHEADER] = $headers;
}
$response = do_curl($curl_opts);
if (!empty($response)) {
$retarr = $response;
}
return $retarr;
}
function do_curl($curl_opts) {
$retarr = array(); // Return value
if (!$curl_opts) {
if ($this->debug) {
$this->logit("do_curl:ERR:curl_opts is empty");
}
return $retarr;
}
// Open curl session
$ch = curl_init();
if (!$ch) {
if ($this->debug) {
$this->logit("do_curl:ERR:curl_init failed");
}
return $retarr;
}
// Set curl options that were passed in
curl_setopt_array($ch, $curl_opts);
// Ensure that we receive full header
curl_setopt($ch, CURLOPT_HEADER, true);
if ($this->debug) {
curl_setopt($ch, CURLINFO_HEADER_OUT, true);
curl_setopt($ch, CURLOPT_VERBOSE, true);
}
// Send the request and get the response
ob_start();
$response = curl_exec($ch);
$curl_spew = ob_get_contents();
ob_end_clean();
if ($this->debug && $curl_spew) {
$this->logit("do_curl:INFO:curl_spew begin");
$this->logit($curl_spew, false);
$this->logit("do_curl:INFO:curl_spew end");
}
// Check for errors
if (curl_errno($ch)) {
$errno = curl_errno($ch);
$errmsg = curl_error($ch);
if ($this->debug) {
$this->logit("do_curl:ERR:$errno:$errmsg");
}
curl_close($ch);
unset($ch);
return $retarr;
}
if ($this->debug) {
$this->logit("do_curl:DBG:header sent begin");
$header_sent = curl_getinfo($ch, CURLINFO_HEADER_OUT);
$this->logit($header_sent, false);
$this->logit("do_curl:DBG:header sent end");
}
// Get information about the transfer
$info = curl_getinfo($ch);
// Parse out header and body
$header_size = curl_getinfo($ch, CURLINFO_HEADER_SIZE);
$header = substr($response, 0, $header_size);
$body = substr($response, $header_size);
// Close curl session
curl_close($ch);
unset($ch);
if ($this->debug) {
$this->logit("do_curl:DBG:response received begin");
if (!empty($response)) {
$this->logit($response, false);
}
$this->logit("do_curl:DBG:response received end");
}
// Set return value
array_push($retarr, $info, $header, $body);
return $retarr;
}
function json_pretty_print($json, $html_output=false) {
$spacer = ' ';
$level = 1;
$indent = 0; // current indentation level
$pretty_json = '';
$in_string = false;
$len = strlen($json);
for ($c = 0; $c < $len; $c++) {
$char = $json[$c];
switch ($char) {
case '{':
case '[':
if (!$in_string) {
$indent += $level;
$pretty_json .= $char . "\n" . str_repeat($spacer, $indent);
} else {
$pretty_json .= $char;
}
break;
case '}':
case ']':
if (!$in_string) {
$indent -= $level;
$pretty_json .= "\n" . str_repeat($spacer, $indent) . $char;
} else {
$pretty_json .= $char;
}
break;
case ',':
if (!$in_string) {
$pretty_json .= ",\n" . str_repeat($spacer, $indent);
} else {
$pretty_json .= $char;
}
break;
case ':':
if (!$in_string) {
$pretty_json .= ": ";
} else {
$pretty_json .= $char;
}
break;
case '"':
if ($c > 0 && $json[$c - 1] != '\\') {
$in_string = !$in_string;
}
default:
$pretty_json .= $char;
break;
}
}
return ($html_output) ?
'<pre>' . htmlentities($pretty_json) . '</pre>' :
$pretty_json . "\n";
}
function oauth_http_build_query($params, $excludeOauthParams=false) {
$query_string = '';
if (!empty($params)) {
// rfc3986 encode both keys and values
$keys = $this->rfc3986_encode(array_keys($params));
$values = $this->rfc3986_encode(array_values($params));
$params = array_combine($keys, $values);
uksort($params, 'strcmp');
$kvpairs = array();
foreach ($params as $k => $v) {
if ($excludeOauthParams && substr($k, 0, 5) == 'oauth') {
continue;
}
if (is_array($v)) {
// If two or more parameters share the same name,
// they are sorted by their value. OAuth Spec: 9.1.1 (1)
natsort($v);
foreach ($v as $value_for_same_key) {
array_push($kvpairs, ($k . '=' . $value_for_same_key));
}
} else {
// For each parameter, the name is separated from the corresponding
// value by an '=' character (ASCII code 61). OAuth Spec: 9.1.1 (2)
array_push($kvpairs, ($k . '=' . $v));
}
}
// Each name-value pair is separated by an '&' character, ASCII code 38.
// OAuth Spec: 9.1.1 (2)
$query_string = implode('&', $kvpairs);
}
return $query_string;
}
function oauth_parse_str($query_string) {
$query_array = array();
if (isset($query_string)) {
// Separate single string into an array of "key=value" strings
$kvpairs = explode('&', $query_string);
// Separate each "key=value" string into an array[key] = value
foreach ($kvpairs as $pair) {
list($k, $v) = explode('=', $pair, 2);
// Handle the case where multiple values map to the same key
// by pulling those values into an array themselves
if (isset($query_array[$k])) {
// If the existing value is a scalar, turn it into an array
if (is_scalar($query_array[$k])) {
$query_array[$k] = array($query_array[$k]);
}
array_push($query_array[$k], $v);
} else {
$query_array[$k] = $v;
}
}
}
return $query_array;
}
function build_oauth_header($params, $realm='') {
$header = 'Authorization: OAuth';
foreach ($params as $k => $v) {
if (substr($k, 0, 5) == 'oauth') {
$header .= ',' . $this->rfc3986_encode($k) . '="' . $this->rfc3986_encode($v) . '"';
}
}
return $header;
}
function oauth_compute_plaintext_sig($consumer_secret, $token_secret) {
return ($consumer_secret . '&' . $token_secret);
}
function oauth_compute_hmac_sig($http_method, $url, $params, $consumer_secret, $token_secret) {
$base_string = $this->signature_base_string($http_method, $url, $params);
$signature_key = $this->rfc3986_encode($consumer_secret) . '&' . $this->rfc3986_encode($token_secret);
$sig = base64_encode(hash_hmac('sha1', $base_string, $signature_key, true));
if ($this->debug) {
logit("oauth_compute_hmac_sig:DBG:sig:$sig");
}
return $sig;
}
/**
* Make the URL conform to the format scheme://host/path
* #param string $url
* #return string the url in the form of scheme://host/path
*/
function normalize_url($url) {
$parts = parse_url($url);
$scheme = $parts['scheme'];
$host = $parts['host'];
$port = $parts['port'];
$path = $parts['path'];
if (!$port) {
$port = ($scheme == 'https') ? '443' : '80';
}
if (($scheme == 'https' && $port != '443')
|| ($scheme == 'http' && $port != '80')) {
$host = "$host:$port";
}
return "$scheme://$host$path";
}
/**
* Returns the normalized signature base string of this request
* #param string $http_method
* #param string $url
* #param array $params
* The base string is defined as the method, the url and the
* parameters (normalized), each urlencoded and the concated with &.
* #see http://oauth.net/core/1.0/#rfc.section.A.5.1
*/
function signature_base_string($http_method, $url, $params) {
// Decompose and pull query params out of the url
$query_str = parse_url($url, PHP_URL_QUERY);
if ($query_str) {
$parsed_query = $this->oauth_parse_str($query_str);
// merge params from the url with params array from caller
$params = array_merge($params, $parsed_query);
}
// Remove oauth_signature from params array if present
if (isset($params['oauth_signature'])) {
unset($params['oauth_signature']);
}
// Create the signature base string. Yes, the $params are double encoded.
$base_string = $this->rfc3986_encode(strtoupper($http_method)) . '&' .
$this->rfc3986_encode($this->normalize_url($url)) . '&' .
$this->rfc3986_encode($this->oauth_http_build_query($params));
$this->logit("signature_base_string:INFO:normalized_base_string:$base_string");
return $base_string;
}
/**
* Encode input per RFC 3986
* #param string|array $raw_input
* #return string|array properly rfc3986 encoded raw_input
* If an array is passed in, rfc3896 encode all elements of the array.
* #link http://oauth.net/core/1.0/#encoding_parameters
*/
function rfc3986_encode($raw_input){
if (is_array($raw_input)) {
//return array_map($this->rfc3986_encode, $raw_input);
return array_map(array($this, 'rfc3986_encode'), $raw_input);
// return $this->rfc3986_encode($raw_input);
} else if (is_scalar($raw_input)) {
return str_replace('%7E', '~', rawurlencode($raw_input));
} else {
return '';
}
}
function rfc3986_decode($raw_input) {
return rawurldecode($raw_input);
}
}
class GmailGetContacts {
function get_request_token($oauth, $usePost=false, $useHmacSha1Sig=true, $passOAuthInHeader=false) {
$retarr = array(); // return value
$response = array();
$url = 'https://www.google.com/accounts/OAuthGetRequestToken';
$params['oauth_version'] = '1.0';
$params['oauth_nonce'] = mt_rand();
$params['oauth_timestamp'] = time();
$params['oauth_consumer_key'] = $oauth->oauth_consumer_key;
$params['oauth_callback'] = $oauth->callback;
$params['scope'] = 'https://www.google.com/m8/feeds';
// compute signature and add it to the params list
if ($useHmacSha1Sig) {
$params['oauth_signature_method'] = 'HMAC-SHA1';
$params['oauth_signature'] =
$oauth->oauth_compute_hmac_sig($usePost ? 'POST' : 'GET', $url, $params,
$oauth->oauth_consumer_secret, null);
} else {
echo "signature mathod not support";
}
// Pass OAuth credentials in a separate header or in the query string
if ($passOAuthInHeader) {
$query_parameter_string = $oauth->oauth_http_build_query($params, FALSE);
$header = $oauth->build_oauth_header($params);
$headers[] = $header;
} else {
$query_parameter_string = $oauth->oauth_http_build_query($params);
}
// POST or GET the request
if ($usePost) {
$request_url = $url;
$oauth->logit("getreqtok:INFO:request_url:$request_url");
$oauth->logit("getreqtok:INFO:post_body:$query_parameter_string");
$headers[] = 'Content-Type: application/x-www-form-urlencoded';
$response = do_post($request_url, $query_parameter_string, 443, $headers);
} else {
$request_url = $url . ($query_parameter_string ?
('?' . $query_parameter_string) : '' );
$oauth->logit("getreqtok:INFO:request_url:$request_url");
$response = $oauth->do_get($request_url, 443, $headers);
}
// extract successful response
if (!empty($response)) {
list($info, $header, $body) = $response;
$body_parsed = $oauth->oauth_parse_str($body);
if (!empty($body_parsed)) {
$oauth->logit("getreqtok:INFO:response_body_parsed:");
//print_r($body_parsed);
}
$retarr = $response;
$retarr[] = $body_parsed;
}
return $body_parsed;
}
function get_access_token($oauth, $request_token, $request_token_secret, $oauth_verifier, $usePost=false, $useHmacSha1Sig=true, $passOAuthInHeader=true) {
$retarr = array(); // return value
$response = array();
$url = 'https://www.google.com/accounts/OAuthGetAccessToken';
$params['oauth_version'] = '1.0';
$params['oauth_nonce'] = mt_rand();
$params['oauth_timestamp'] = time();
$params['oauth_consumer_key'] = $oauth->oauth_consumer_key;
$params['oauth_token'] = $request_token;
$params['oauth_verifier'] = $oauth_verifier;
// compute signature and add it to the params list
if ($useHmacSha1Sig){
$params['oauth_signature_method'] = 'HMAC-SHA1';
$params['oauth_signature'] =
$oauth->oauth_compute_hmac_sig($usePost ? 'POST' : 'GET', $url, $params,
$oauth->oauth_consumer_secret, $request_token_secret);
} else {
echo "signature mathod not support";
}
//
if ($passOAuthInHeader) {
$query_parameter_string = $oauth->oauth_http_build_query($params, false);
$header = $oauth->build_oauth_header($params);
$headers[] = $header;
} else {
$query_parameter_string = $oauth->oauth_http_build_query($params);
}
if ($usePost){
$request_url = $url;
logit("getacctok:INFO:request_url:$request_url");
logit("getacctok:INFO:post_body:$query_parameter_string");
$headers[] = 'Content-Type: application/x-www-form-urlencoded';
$response = $oauth->do_post($request_url, $query_parameter_string, 443, $headers);
} else {
$request_url = $url . ($query_parameter_string ?
('?' . $query_parameter_string) : '' );
$oauth->logit("getacctok:INFO:request_url:$request_url");
$response = $oauth->do_get($request_url, 443, $headers);
}
if (!empty($response)) {
list($info, $header, $body) = $response;
$body_parsed = $oauth->oauth_parse_str($body);
if (!empty($body_parsed)) {
$oauth->logit("getacctok:INFO:response_body_parsed:");
//print_r($body_parsed);
}
$retarr = $response;
$retarr[] = $body_parsed;
}
return $body_parsed;
}
function GetContacts($oauth, $access_token, $access_token_secret, $usePost=false, $passOAuthInHeader=true,$emails_count) {
$retarr = array(); // return value
$response = array();
$url = "https://www.google.com/m8/feeds/contacts/default/full";
$params['alt'] = 'json';
$params['max-results'] = $emails_count;
$params['oauth_version'] = '1.0';
$params['oauth_nonce'] = mt_rand();
$params['oauth_timestamp'] = time();
$params['oauth_consumer_key'] = $oauth->oauth_consumer_key;
$params['oauth_token'] = $access_token;
// compute hmac-sha1 signature and add it to the params list
$params['oauth_signature_method'] = 'HMAC-SHA1';
$params['oauth_signature'] =
$oauth->oauth_compute_hmac_sig($usePost ? 'POST' : 'GET', $url, $params,
$oauth->oauth_consumer_secret, $access_token_secret);
// Pass OAuth credentials in a separate header or in the query string
if ($passOAuthInHeader){
$query_parameter_string = $oauth->oauth_http_build_query($params, false);
$header = $oauth->build_oauth_header($params);
$headers[] = $header;
} else {
$query_parameter_string = $oauth->oauth_http_build_query($params);
}
// POST or GET the request
if ($usePost){
$request_url = $url;
$oauth->logit("callcontact:INFO:request_url:$request_url");
$oauth->logit("callcontact:INFO:post_body:$query_parameter_string");
$headers[] = 'Content-Type: application/x-www-form-urlencoded';
$response = $oauth->do_post($request_url, $query_parameter_string, 80, $headers);
} else {
$request_url = $url . ($query_parameter_string ?
('?' . $query_parameter_string) : '' );
$oauth->logit("callcontact:INFO:request_url:$request_url");
$response = $oauth->do_get($request_url, 443, $headers);
}
if (!empty($response)) {
list($info, $header, $body) = $response;
if ($body) {
$oauth->logit("callcontact:INFO:response:");
$contact = json_decode($oauth->json_pretty_print($body), true);
//echo $contact['feed']['entry'][0]['gd$email'][0]['address'];
return $contact['feed']['entry'];
}
$retarr = $response;
}
return $retarr;
}
}
?>
Can you guys help me on this one please. Thanks in advance!
Not sure if this can help you as you say you have already used print_r (are you using with braces?), but to display the contents of an array in PHP, I have always used this with success.
It displays the integer ref of the array plus the data in each field.
<?php
echo "<pre>"; //print array to console
{print_r($variable_name);}
echo "</pre>";
?>
Alternately, have you checked the information here: https://developers.google.com/google-apps/contacts/v3/#retrieving_contacts_using_query_parameters
Or try the Context.IO API - there's a call specifically for pulling contacts: http://context.io/docs/2.0/accounts/contacts
Hoping any of these might help you.
For your case for first Phone andress and Note Field .
add where you loop the contacts in gmail.php
foreach($contacts as $k => $a)
{
$phone1 = end($a['gd$phoneNumber'][0]);
$note = end($a['content']);
$adress = end($a['gd$postalAddress'][0]);
The snippet is from importMsnm.class.php,$data = $this->_get(); returns false on the 2nd time of loop, it worked before :
VER 1 MSNP9 CVR0
VER 1 CVR0
CVR 1 0x0409 win 4.10 i386 MSNMSGR 7.0.0816 MSMSGS username#hotmail.com
connection is lost
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");
return array();
} 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;
}
}
}
}
It seems like they've once again locked out old clients. Microsoft do this once in a while to make third party clients unusable. Their standard way of handling protocol exceptions is to immediately tearing down the connection.