Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9192253
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T20:52:40+00:00 2026-06-17T20:52:40+00:00

Are there any posts/tutorials about accessing Google Contact API with CodeIgniter framework? I have

  • 0

Are there any posts/tutorials about accessing Google Contact API with CodeIgniter framework?
I have googled it a lot found just one post which using Zend Libraries with Codeigniter.
Went through some PHP implementation of Contact API. But all of them are using Curl to talk to API.
Can I use the same way as a Codeigniter model class? or should I consider accessing gmail contacts using javascript?

Please help.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T20:52:41+00:00Added an answer on June 17, 2026 at 8:52 pm

    I used oauth library for codeigniter
    http://getsparks.org/packages/oauth2/versions/HEAD/show

    set scope in the spark->oauth->libries->provider->google like

    public function __construct(array $options = array()) {
        // Now make sure we have the default scope to get user data
        empty($options['scope']) and $options['scope'] = array(
            'https://www.googleapis.com/auth/userinfo.profile',
            'https://www.googleapis.com/auth/userinfo.email',
            'https://www.google.com/m8/feeds',
        );
    

    Add following code in the same file

    public function curl_file_get_contents($email, OAuth2_Token_Access $token) {
        $url = "https://www.google.com/m8/feeds/contacts/$email/full?max-results=" . 25 . "&oauth_token=" . $token->access_token;
        $curl = curl_init();
        $userAgent = 'Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; .NET CLR 1.1.4322)';
        curl_setopt($curl, CURLOPT_URL, $url); //The URL to fetch. This can also be set when initializing a session with curl_init().
        curl_setopt($curl, CURLOPT_RETURNTRANSFER, TRUE); //TRUE to return the transfer as a string of the return value of curl_exec() instead of outputting it out directly.
        curl_setopt($curl, CURLOPT_CONNECTTIMEOUT, 5); //The number of seconds to wait while trying to connect. 
    
        curl_setopt($curl, CURLOPT_USERAGENT, $userAgent); //The contents of the "User-Agent: " header to be used in a HTTP request.
        curl_setopt($curl, CURLOPT_FOLLOWLOCATION, TRUE); //To follow any "Location: " header that the server sends as part of the HTTP header.
        curl_setopt($curl, CURLOPT_AUTOREFERER, TRUE); //To automatically set the Referer: field in requests where it follows a Location: redirect.
        curl_setopt($curl, CURLOPT_TIMEOUT, 10); //The maximum number of seconds to allow cURL functions to execute.
        curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, 0); //To stop cURL from verifying the peer's certificate.
        curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, 0);
    
        $contents = curl_exec($curl);
        curl_close($curl);
    
        return $contents;
    }
    

    then used this code for the google contant in controller

    public function google() {
            $this->load->helper('url_helper');
            $this->load->spark('oauth2');
            $provider = $this->oauth2->provider('google', array(
                'id' => GOOGLE_APP_ID,
                'secret' => GOOGLE_APP_SECRET,
                    ));
    
            if (!$this->input->get('code')) {
                // By sending no options it'll come back here
                $provider->authorize();
            } else {
                // Howzit?
                try {
                    $token = $provider->access($_GET['code']);
    
                    $user = $provider->get_user_info($token);
                    $email = $user['email'];
    
                    $xmlresponse = $provider->curl_file_get_contents($email, $token);
                    if ((strlen(stristr($xmlresponse, 'Authorization required')) > 0) && (strlen(stristr($xmlresponse, 'Error ')) > 0)) {
                        echo "<h2>OOPS !! Something went wrong. Please try reloading the page.</h2>";
                        exit();
                    }
                    $xml = new SimpleXMLElement($xmlresponse);
                    $xml->registerXPathNamespace('gd', 'http://schemas.google.com/g/2005');
                    $result = $xml->xpath('//gd:email');
                    $this->data['email_address'] = $result;
    print_r($result);exit;
                } catch (OAuth2_Exception $e) {
                    show_error('That didnt work: ' . $e);
                }
            }
    
        }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Is there any way to ensure that a class posts a particular NSNotification? (I
Is there any solution to detecting if a POST have been sent with jQuery?
There seem to be very few tutorials out there about how to write a
Hi guys I've read a lot of article and tutorials in the internet about
Is there any way to post large files (>150MB) to Dropbox service with Spring
Is there any way to accept POST type requests without using Nerve lib in
is there any reason to use the post-redirect-get (prg) for a request that you
Is there any way to do some kind of while() for each post variable
Search for good JAVA lib for playing with POST-GET requests - Is there any
i want to code something in my post template. So, is there any way

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.