简体   繁体   English

致命错误:未捕获的错误:C:\xampp\htdocs\imagebob\google-drive.php:41 中未定义的常量“STDIN”

[英]Fatal error: Uncaught Error: Undefined constant “STDIN” in C:\xampp\htdocs\imagebob\google-drive.php:41

when I try to want access the token the verification code is not working and they give me error undefined constant "STDIN" im new here in google API so please help me what's I do?当我试图访问令牌时,验证码不起作用,他们给我错误未定义的常量“STDIN”我在谷歌 API 中是新的,所以请帮我做什么? Thanks谢谢

if ($client->isAccessTokenExpired()) {
    // Refresh the token if possible, else fetch a new one.
    if ($client->getRefreshToken()) {
        $client->fetchAccessTokenWithRefreshToken($client->getRefreshToken());
    } else {
        // Request authorization from the user.
        $authUrl = $client->createAuthUrl();
        printf("Open the following link in your browser:\n%s\n", $authUrl);
        print 'Enter verification code: ';
        $authCode = trim(fgets(STDIN));

        // Exchange authorization code for an access token.
        $accessToken = $client->fetchAccessTokenWithAuthCode($authCode);
        $client->setAccessToken($accessToken);

        // Check to see if there was an error.
        if (array_key_exists('error', $accessToken)) {
            throw new Exception(join(', ', $accessToken));
        }
    }
    // Save the token to a file.
    if (!file_exists(dirname($tokenPath))) {
        mkdir(dirname($tokenPath), 0700, true);
    }
    file_put_contents($tokenPath, json_encode($client->getAccessToken()));
}

The example code on the quickstart tells you use the php command . 快速入门上的示例代码告诉您使用php命令 This means that you are executing it on a console/terminal where you have STDIN .这意味着您正在拥有STDIN的控制台/终端上执行它。

If you are trying to do a web server application, you don't have it and thus the code is different.如果您尝试做一个 web 服务器应用程序,您没有它,因此代码是不同的。 You can find the most common setups on the library's GitHub repository ( see examples ).您可以在库的 GitHub 存储库中找到最常见的设置(参见示例)。 Take a look to them, understand their differences, and choose the one that's best for you.看看他们,了解他们的差异,然后选择最适合您的。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 致命错误:未捕获错误:调用 C:\\xampp\\htdocs\\phpmvc\\app\\models\\Mahasiswa_model.php:31 中未定义的函数 query() - Fatal error: Uncaught Error: Call to undefined function query() in C:\xampp\htdocs\phpmvc\app\models\Mahasiswa_model.php:31 致命错误:未捕获错误:调用 C:\\xampp\\htdocs\\ 中未定义的函数 mysql_connect() - Fatal error: Uncaught Error: Call to undefined function mysql_connect() in C:\xampp\htdocs\ PHP 致命错误:未捕获错误:Class 在 C:\xampp\htdocs\server\pdf.php:5 中未找到“Mpdf\Mpdf” - PHP Fatal error: Uncaught Error: Class "Mpdf\Mpdf" not found in C:\xampp\htdocs\server\pdf.php:5 致命错误:未捕获错误:在C:\\ xampp \\ htdocs \\ oophp \\ Home.php中调用成员函数connect()时为null - Fatal error: Uncaught Error: Call to a member function connect() on null in C:\xampp\htdocs\oophp\Home.php Fatal error: Uncaught Error: Call to a member function query() on null in C:\xampp\htdocs\shop\index.php - Fatal error: Uncaught Error: Call to a member function query() on null in C:\xampp\htdocs\shop\index.php 致命错误:第 19 行在 C:\\xampp\\htdocs\\register.php 中抛出未捕获的异常“PDOException” - Fatal error: Uncaught exception 'PDOException' thrown in C:\xampp\htdocs\register.php on line 19 致命错误:在第53行的C:\\ xampp \\ htdocs \\ webdev \\ div.php中调用未定义的功能countdown() - Fatal error: Call to undefined function countdown() in C:\xampp\htdocs\webdev\div.php on line 53 致命错误:在第101行的C:\\ xampp \\ htdocs \\ Employees.php中调用未定义的函数getRecords() - Fatal error: Call to undefined function getRecords() in C:\xampp\htdocs\Employees.php on line 101 PHP致命错误:在C:\\ xampp \\ htdocs \\中找不到类“线程化” - PHP Fatal error: Class 'Threaded' not found in C:\xampp\htdocs\ 提交后:PHP致命错误:在C:\\ xampp \\ htdocs \\中找不到类 - After submit: PHP Fatal error: Class not found in C:\xampp\htdocs\
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM