PHP Gmail Contacts Import - Help

Hi

So I found a script on the internet that actually imports the contacts of your gmail once you provide a correct gmail username / password.

I have attached 2 zip files with this post.

working_example.zip - Contains the working example of the script. Returns the contacts in an array() format on success.

not_working_example.zip - I wanted to implement this script using class. So I went ahead and wrapped the code in a class and created an instance of the class, but when I tried to call the method, it generated the following error:

Warning:  curl_exec() [function.curl-exec]: Could not call the CURLOPT_HEADERFUNCTION in D:\
ot_working_example\\gmail.api.include.php on line 36

Warning:  curl_exec() [function.curl-exec]: Could not call the CURLOPT_HEADERFUNCTION in D:\
ot_working_example\\gmail.api.include.php on line 65

Please, if anyone can help me figuring out the issue, I will be greatful.

I am guessing this has something to do with scopes in OOP, but not sure what…pls help :slight_smile:

Many thanks

Hey cancer,

The CURLOPT_HEADERFUNCTION constant is the name of a function to be called - however the function ‘read_header’ doesn’t exist - the function ‘read_header’ INSIDE the class ‘gmail’ does however.

Try changing this line

curl_setopt($ch, CURLOPT_HEADERFUNCTION, 'read_header');

to this

curl_setopt($ch, CURLOPT_HEADERFUNCTION,array($this, 'read_header'));

Works like a charm…many thanks for your kind help

Hi cancer

I want to implement the same the same importing contacts from gmail,yahoo,orkut,hotmail

Can u plz help me in this

regard’s
girish
girish@gmail.com

Try to ask for source instead of direct source code.
Else you will be left somewhere in the middle of the ocean :wink:

hi phpycho

Thanks for ur reply …
any how can u help me to complete this…

Since i have deal with such issues.
What else can i say is search this forum & google with the related keyword.
Also you can give a try in phpclasses.org site.
Thanks

ya i downloaded from that only

i am getting this error

Deprecated: Function eregi() is deprecated in C:\wamp\www\project\contactgrabber\index.php on line 30

Please read the warning section of this link:
http://php.net/eregi

ok… can u tell how display the out put in line format instead of displaying array as i need to give check to the output.

code is here…

//---------------------------------------------//
<?php

if(isset($_POST[‘submitcontacts’])){
include(“gmail.api.include.php”);
function getContacts($username = null, $password = null){

//$username = $_POST['uname'];
//$password = $_POST['pwd'];

//$login = $username;
//$password = $password;

$resultarray = get_contacts($_POST[‘uname’], $_POST[‘pwd’]);

foreach($resultarray as $res){
	$emailArray['email'] = $res;
}

return $emailArray;

}

print_r(getContacts("GMAIL_USERNAME","GMAIL_PASSWORD"));

}
?>
//--------------------------------------------//

regard’s
girish

Hi Cancer,

at least tell me how to display the out put in row wise instead of displaying in array index please help me out…

//-------------------------------------//

<?php

if(isset($_POST[‘submitcontacts’])){
include(“gmail.api.include.php”);
function getContacts($username = null, $password = null){

//$username = $_POST['uname'];
//$password = $_POST['pwd'];

//$login = $username;
//$password = $password;

$resultarray = get_contacts($_POST[‘uname’], $_POST[‘pwd’]);

foreach($resultarray as $res){
	$emailArray['email'] = $res;
}

return $emailArray;

}

print_r(getContacts("GMAIL_USERNAME","GMAIL_PASSWORD"));

}
?>
//-------------------------------------//

Regard’s
Girish
girish@pbminfotech.com