Internet

Gmail Contact Grabber – Php class

June 19, 2010 by Sarath DR in Internet, Web Development with 22 Comments
Contact grabber Gmail Contact Grabber   Php class

Gmail Contact Grabber Php Class

Most of the social media websites have the facility to fetch the contacts in our address book. This is probably being used to find friends network. This is a simple php class based on Google’s client login API to fetch contact details someone’s gmail Id. Curl must be enabled in your server for the proper working of this library. You should also need to register your application to Google for authentication which is very simple and includes only two steps.
The following link helps you to register the website.

https://www.google.com/accounts/ManageDomains

If you require more information about Google Client Login API click here

To download the class file click here

download Gmail Contact Grabber   Php class

Following sample code snipplet shows How to use the Gmail Contact Grabber library.

 
<?php
/* 
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
 
 
 
include "Gmail_contacts.php";
if( isset( $_POST['email_submit']) )
{
 
   // First parameter is the offset 
   // Second parameter is the starting index. 
 
   $grabber = new Gmail_contacts(1000, 1 );
   $emails = $grabber->get_contacts( $_POST['email'] , $_POST['password'] );
 
}
 
 
?>
 
 
 
 
<form action="<?=$_SERVER['PHP_SELF'];?>" method="post">
 
    Email:  <input type="text" name="email" /> <br>
    Password: <input type="password"  name="password" />
    <br>
    <input type="submit" name="email_submit" />
 
</form>
 
 
<?php if( isset( $emails ) && count($emails) > 0  ): ?>
<?php foreach(  $emails as $email ): ?>
 
<input type="checkbox" name="conttact[]" value="<?=$email['email'];?>" /> <?=$email['email'];?><br>
 
<?php endforeach;?>
 
<?php endif; ?>

Tagged , , , , , ,

Share this to

Related Posts

22 Comments

  1. VasudevAug 13, 2010 at 2:32 amReply

    Awesome scripts.
    Thanks

  2. AnkanAug 27, 2010 at 7:49 pmReply

    after putting username and password it is showing “Access forbidden!,Error 403″. pls help me….

  3. Sarath D RAug 27, 2010 at 8:22 pmReplyAuthor

    Did you register your website with google?

  4. Sarath D RSep 7, 2010 at 3:52 amReplyAuthor

    Thanks vasudev!!

  5. kilottoFeb 7, 2011 at 10:54 pmReply

    Great!

  6. robertFeb 24, 2011 at 2:17 pmReply

    Hello, cant make the script work, $response = curl_exec($ch); returns false, what could be wrong? please help

  7. Sarath D RFeb 24, 2011 at 3:31 pmReplyAuthor

    Did you register with Google ??

  8. robertFeb 24, 2011 at 4:59 pmReply

    i didnt register, because i am running this script on localhost.. hmm :)

  9. Sarath D RFeb 24, 2011 at 5:03 pmReplyAuthor

    It wont work in localhost …You have to upload to the domain.

  10. Rahul SharmaMar 16, 2011 at 4:46 amReply

    The script is awesome and very helpful.

    But I also want to show error messages if authentication failed like if user enter wrong email or password.

    Please help me on this

  11. Iqbal hussianMar 18, 2011 at 8:01 amReply

    how to grab email from only email address and that email address’s address book?? any idea like facebook they sends email to registered email’s address book emails

  12. CarlosMar 23, 2011 at 3:57 pmReply

    This script works ….. What is the script for yahoo and hotmail?

    este script funciona….. ¿cual es el script para yahoo y hotmail?

  13. Ebot TabiApr 16, 2011 at 6:36 amReply

    Hi nice script, perfect working well on localhost, good for integration with Kohana 2.3 and Kohana 3. any plans for a yahoo script will be helpful for me, will definitely keep an eagle eye on your articles.

    thanks

  14. anurajMay 7, 2011 at 8:52 pmReply

    how can i sent group scrap in orkut

  15. james bondJul 24, 2011 at 1:29 pmReply

    thanx for nice script

  16. halfsaintAug 8, 2011 at 2:38 pmReply

    Respected,

    i used your code in my website but its not working properly. its always return NULL when i login and grant permission.
    please help me…

  17. SarathApr 5, 2012 at 3:24 pmReply

    @halfsaint have you register your website with google

    • adminApr 5, 2012 at 3:26 pmReplyAuthor

      You have to register the website first ..

  18. hosseinJun 18, 2012 at 4:54 amReply

    hi, i can not grab gmail contacts,
    return error below:
    Deprecated: Function split() is deprecated in /home/bikbikne/public_html/grab gmail/Gmail Contact Grabber/Gmail_contacts.php on line 50

    plz help me

  19. vasanthJul 25, 2013 at 4:37 amReply

    i am getting below mentioned error, can anybody help me out:

    Deprecated: Function split() is deprecated in /home/asalta/public_html/workshop/vasanth/gmail grabber/Gmail_contacts.php on line 50

    • adminJul 25, 2013 at 10:13 amReplyAuthor

      I will check this and get back to you

  20. sagnikMar 22, 2014 at 12:53 pmReply

    Very nice.. But after running this on my domain it showed nothing. I have already registered my application with name of my domain…do I have to put client ID and client Secret here. If so then where exactly in the code??

Leave a reply

Your email address will not be published. Required fields are marked *

*

About
View Sarath D R's profile on LinkedIn

I am a technology consultant and an entrepreneur focused on the following technologies Java,Spring, Android, Angular, Asterisk, Symfony, Cake , Code-Igniter, Jquery , XAMPP, XHTML, AJAX, MySql, Seo, Web Design, Wordpress, iPhone development.

Today’s Tips
  • Generate Codova.jar file from Phonegap project using ant
  • Google map javascript client  to find the geographic co-ordinates  from  Address or post code
  • Update Android main UI from Webview – Phonegap Plugin
  • Jplayer is not working  with HTC One Android 4.3 version browser
  • Regular expression to validate mobile phone numbers starting with + ( plus ) – php
  • Simple pagination script for PHP
  • Useful adb ( Android Debug Bridge ) commands
  • Change the javascript files url to absolute url – Symfony 1.4
  • Set Http authentication header from Client – PHP / CURL

This site uses cookies from Google to deliver its services, to personalise ads and to analyse traffic. Information about your use of this site is shared with Google. By using this site, you agree to its use of cookies. more information

The cookie settings on this website are set to "allow cookies" to give you the best browsing experience possible. If you continue to use this website without changing your cookie settings or you click "Accept" below then you are consenting to this.This site also uses cookies from Google to deliver its services, to personalise ads and to analyse traffic. Information about your use of this site is shared with Google. By using this site, you agree to its use of cookies.

Close