I'm pretty new at this but I've been trying to use the google calendar API to show upcoming events on a website I'm making. So far I've enabled the API and created a service account to access the calendar. I've been using the instructions from another stackoverflow post but I keep getting an error. I believe this is the code that is causing it:
//set environment variable to use your downloaded Service account key
putenv("GOOGLE_APPLICATION_CREDENTIALS=myCredentials.json");
I have myCredentials.json
in the same folder as the php file containing the above code. However when I test the code i get the following error:
Fatal error: Uncaught DomainException: Unable to read the credential file specified by GOOGLE_APPLICATION_CREDENTIALS: file myCredentials.json does not exist
I'm not sure if I should be placing myCredentials.json
in a different location or did I not specify the path correctly?
Update: I fixed it by using an absolute path. In my case I just had to prepend /Applications/MAMP/htdocs/
since I was using MAMP.