Posted on 20-08-2009
Filed Under (general) by Elfin Ruler

Gmail Address Importer

<?php

$ loginusername = urlencode(“test@gmail.com”);

$loginpassword = urlencode(“1234567”);

//First  read gmail login pages

$ch = curl_init();

//curl url

curl_setopt($ch, CURLOPT_URL,”http://gmail.com”);

curl_setopt($ch, CURLOPT_REFERER, “”);

curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);

curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);

curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);

$agent = “Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.4)

Gecko/20030624 Netscape/7.1 (ax)”;

$cookie_file_path = “C:/Inetpub/wwwroot/spiders/cookie/cook”; // Please

set your Cookie File path. This file must have CHMOD 777 (Full Read /

Write Option).

curl_setopt($ch, CURLOPT_COOKIEFILE, $cookie_file_path);

curl_setopt($ch, CURLOPT_COOKIEJAR, $cookie_file_path);

$html = curl_exec($ch);

$location = “https://www.google.com/accounts/ServiceLoginAuth”;

$matches = array();

preg_match_all(‘/<input type\=”hidden” name\=”([^"]+)” value\=”([^"]*)”[^>]*>/’, $html, $matches);

$values = $matches[2];

$params = “”;

$i=0;

foreach ($matches[1] as $name)

{

$params .= “$name=” . urlencode($values[$i]) . “&”;

++$i;

}

curl_setopt($ch, CURLOPT_URL,$location);

curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);

curl_setopt($ch, CURLOPT_POST, 1);

curl_setopt($ch, CURLOPT_POSTFIELDS, $params .”Email=”.$ loginusername.”&Passwd=”.$ loginpassword.”&PersistentCookie=”);

curl_setopt($ch, CURLOPT_COOKIEFILE, $cookie_file_path);

curl_setopt($ch, CURLOPT_COOKIEJAR, $cookie_file_path);

$html = curl_exec($ch);

if (eregi(“Username and password do not match”, $html))

{

curl_close ($ch);

unlink($cookie_file_path);

return 1;

}

$ch = curl_init();

$location = “https://mail.google.com/mail/?ui=html&zy=f”;

curl_setopt($ch, CURLOPT_URL, $location);

curl_setopt($ch, CURLOPT_USERAGENT, $agent);

curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);

curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);

curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);

curl_setopt($ch, CURLOPT_COOKIEFILE, $cookie_file_path);

curl_setopt($ch, CURLOPT_COOKIEJAR, $cookie_file_path);

$html = curl_exec($ch);

curl_close ($ch);

$location = “https://mail.google.com/mail/contacts/data/export?groupToExport=&exportType=ALL&out=HTML&exportEmail=true”;

$ch = curl_init();

curl_setopt($ch, CURLOPT_URL, $location);

curl_setopt($ch, CURLOPT_USERAGENT, $agent);

curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);

curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);

curl_setopt($ch, CURLOPT_COOKIEFILE, $cookie_file_path);

curl_setopt($ch, CURLOPT_COOKIEJAR, $cookie_file_path);

$result = curl_exec($ch);

curl_close ($ch);

unlink($cookie_file_path);

$result = str_replace(“\n”, “”, $result);

$result = str_replace(“\r”, “”, $result);

if (!empty($result))

{

$csv = array();

preg_match_all(‘|<tr><td>(.*?)</td><td>(.*?)</td></tr>|’, $result, $csv);

//preg_match_all(‘|(.*?),(.*?),|’, $result, $csv);

$users = $csv[1];

$emails = $csv[2];

foreach ( $users as $id => $user ) {

$user = (empty($user) || ($user == ‘-’)) ? $emails[$id] : $user;

Echo $ user. $emails[$id];

}

}

?>

(0) Comments    Read More   
BACK-LINKS and PAGE-RANK WEB DIRECTORY