Reputation: 49
I'm trying to install the google api for PHP, following this tutorial https://developers.google.com/drive/quickstart-php#step_1_enable_the_drive_api I downloaded the source files from this website: http://code.google.com/p/google-api-php-client/ but when they said run a command I couldn't figure out how to do that, because I'm hosting off lunarpages and the source files for my website are not downloaded on my computer, so I'm a noob at that part, but it would seem like the files i downloaded from the previous website should work. So I uploaded them to my source directory( after creating an O.Auth 2.0 Client Id of course) and created the document.txt test file and the quickstart.php with the same code as in the tutorial website but with my client id + secret. Now when I browse the page online I get the following error:
Please visit: https://accounts.google.com/o/oauth2/auth?response_type=code&redirect_uri=urn%3Aietf%3Awg%3Aoauth%3A2.0%3Aoob&client_id=136782384170-5sr0a78ffs2kicvpubursmj1k29obgcg.apps.googleusercontent.com&scope=https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fdrive&access_type=offline&approval_prompt=force Please enter the auth code: Warning: fgets() expects parameter 1 to be resource, string given in /home/dpnews0/public_html/dpreads0/quickstart.php on line 19 Warning: Cannot modify header information - headers already sent by (output started at /home/dpnews0/public_html/dpreads0/quickstart.php:17) in /home/dpnews0/public_html/dpreads0/google-api-php-client/src/auth/Google_OAuth2.php on line 118 Fatal error: Uncaught exception 'Google_AuthException' with message 'Could not json decode the token' in /home/dpnews0/public_html/dpreads0/google-api-php-client/src/auth/Google_OAuth2.php:153 Stack trace: #0 /home/dpnews0/public_html/dpreads0/google-api-php-client/src/Google_Client.php(174): Google_OAuth2->setAccessToken(NULL) #1 /home/dpnews0/public_html/dpreads0/quickstart.php(23): Google_Client->setAccessToken(true) #2 {main} thrown in /home/dpnews0/public_html/dpreads0/google-api-php-client/src/auth/Google_OAuth2.php on line 153
Anyone have any ideas/past experience with this you think you can help me with?
Upvotes: 1
Views: 1131
Reputation: 1
A solution : put ob_start(); and ob_end_clean(); on your code :
ob_start();
Here, your Google API code
ob_end_clean();
// And after, the redirection header('location:page.php'); exit;
Upvotes: 0
Reputation: 1
Try to clear cookies or use different browser. api stores your token in session
Upvotes: 0