Google api + php + codeigniter + curl Google api + php + codeigniter + curl codeigniter codeigniter

Google api + php + codeigniter + curl


First you need to get access token.

require_once 'google-api-php-client/autoload.php';$client = new Google_Client();$client->setApplicationName("Client_Library_Examples");$client->setDeveloperKey("YOUR_PUBLIC_API_ACCESS_KEY");$client->setScopes(array('https://www.googleapis.com/auth/plus.me'));$client->setClientId('CLIENT_ID');$client->setClientSecret('CLIENT_SECRET');$client->setApprovalPrompt('force');$client->setAccessType('offline');$client->setRedirectUri('http://yourdomain.com/oauthCallback');$access_token = '';if (!isset($_GET['code'])) {    redirect($client->createAuthUrl());} else {    // Exchanging code with access token    $client->authenticate(urldecode($_GET['code'])); // Exchange code for auth    $access_token = $client->getAccessToken(); // Get access token    // Send your curl request to any api with access token here and get data}

This is the general flow. You should first take look at the implementing OAuth here in official documentation.

Once you have access token you can make REST call to any api, but before that you must specify scopes which feature you want to access.