I keep getting this fatal error.
Fatal error: Uncaught exception 'Google_IO_Exception' with message 'HTTP Error: Unable to connect: 'fopen(https://accounts.google.com/o/oauth2/token): failed to open stream: php_network_getaddresses: getaddrinfo failed: No such host is known. ''
I am accessing it by a localhost on another computer using my network. I just attempted to reboot it and see it that solved it by some weird means. Did not work.
Here is my file.
$client_id = $jsonDecode['client_id'];
$Email_address = $jsonDecode['client_email'];
$key_file_location = 'privateKey.p12';
$client = new Google_Client();
$client->setApplicationName("<APP NAME>");
$key = file_get_contents($key_file_location);
// separate additional scopes with a comma
$scopes ="https://www.googleapis.com/auth/calendar.readonly";
$cred = new Google_Auth_AssertionCredentials(
$Email_address,
array($scopes),
$key
);
$client->setAssertionCredentials($cred);
if($client->getAuth()->isAccessTokenExpired()) {
$client->getAuth()->refreshTokenWithAssertion($cred);
}
$service = new Google_Service_Calendar($client);