This is the code I have written to fetch the calendar events from Google Calendar. On running this in localhost, it takes the permission from the user but shows
Fatal error: Uncaught exception 'GuzzleHttp\Exception\RequestException' with message 'cURL error 60: SSL certificate problem: unable to get local issuer certificate (see http://curl.haxx.se/libcurl/c/libcurl-errors.html)' in D:\wamp\www\google-api-php-client-2.0.0-RC4\vendor\guzzlehttp\guzzle\src\Handler\CurlFactory.php on line 187
( ! ) GuzzleHttp\Exception\RequestException: cURL error 60: SSL certificate problem: unable to get local issuer certificate (see http://curl.haxx.se/libcurl/c/libcurl-errors.html) in D:\wamp\www\google-api-php-client-2.0.0-RC4\vendor\guzzlehttp\guzzle\src\Handler\CurlFactory.php on line 187
I tried adding cacert.pem path's in php.ini and other mentioned things over other forums. Nothing worked. I tried putting the file online in a server(Centos). Installed composer too. But there, when I try to load the page nothing shows.
As far as I think, there the autoload.php inside vendor of Google api package does not return anything.
return ComposerAutoloaderInitd82ee48119182e2321ebd694e70287c2::getLoader();
Where am I going wrong? Or, is there something wrong with the code?
session_start();
require_once './google-api-php-client-2.0.0-RC4/vendor/autoload.php';
set_include_path(get_include_path() . PATH_SEPARATOR . './google-api-php-client-2.0.0-RC4/src');
$google_client_id = '...';
$google_client_secret = '...';
$google_redirect_uri = 'http://localhost/gapicc.php';
$client = new Google_Client();
$client -> setApplicationName('Sample');
$client -> setClientid($google_client_id);
$client -> setClientSecret($google_client_secret);
$client -> setRedirectUri($google_redirect_uri);
$client -> setAccessType('online');
$client -> setScopes(Google_Service_Calendar::CALENDAR);
$googleImportUrl = $client -> createAuthUrl();
if(isset($_GET['code']))
{
$auth_code = $_GET['code'];
$client->authenticate($_GET['code']);
$access_token = $client->getAccessToken();
$calendar_service = new Google_Service_Calendar($client);
$calendar_list = $calendar_service->calendarList->listCalendarList(array())->getItems();
echo json_encode($calendar_list);
}
echo filter_var($googleImportUrl, FILTER_SANITIZE_URL); // Path where I am heading the user when he clicks "Import Google Calendar"