我正在尝试按照本教程https://developers.google.com/drive/quickstart-php#step_1_enable_the_drive_api安装适用于PHP的google api 我从这个网站下载了源文件:http://code.google.com/p/google-api-php-client/但是当他们说运行命令时我无法弄清楚如何做到这一点,因为我正在托管月球页面并且我的网站的源文件没有下载到我的电脑,所以我是那个部分的菜鸟,但看起来我从上一个网站下载的文件应该可行。所以我将它们上传到我的源目录(当然在创建了O.Auth 2.0 Client Id之后)并创建了document.txt测试文件和quickstart.php,其代码与教程网站中的相同,但我的客户端ID为+ secret 。现在,当我在线浏览页面时,出现以下错误:
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
任何人都有任何想法/过去的经验,你认为你可以帮助我吗?
答案 0 :(得分:0)
尝试清除Cookie或使用其他浏览器。 api将您的令牌存储在会话中
答案 1 :(得分:0)
解决方案:把ob_start();和ob_end_clean();在您的代码上:
ob_start();
此处为您的Google API代码
ob_end_clean();
//之后,重定向 报头('位置:page.php文件&#39); 出口;