解析错误:语法错误,意外的'?',设置Google注册时需要变量T_VARIABLE

问题描述

我在Google注册过程中遇到问题。我的网站在核心php中。在开始运作的一个月前,突然停了下来。

当我单击“使用Google登录”按钮时,它提示我选择电子邮件。当我选择“选择要继续处理的电子邮件”后,它显示错误。

错误:

解析错误:语法错误,意外的“?”,在public_html /.../ google-api-php-client-2.6.0 / vendor / guzzlehttp / guzzle / src / ClientInterface.php中期望变量(T_VARIABLE)第81行

屏幕截图:

enter image description here

https://prnt.sc/u24103

我搜索了很多,但没有任何解决方案。我当时使用的是2.6.0版,但尝试将其替换为2.7版,但没有成功。

请帮助。 谢谢

这是我的代码

require_once('includes/config.php');

 require_once(DOCUMENT_ROOT . '/demo/tutor-student/google-api-php-client-2.6.0/vendor/autoload.php');

 define('GOOGLE_CLIENT_ID','XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX.apps.googleusercontent.com');
 define('GOOGLE_CLIENT_SECRET','xxxxxxxxxxxxxxxxxxxxxxx');
 define('GOOGLE_REDIRECT_URL',BASE_URL.'admin/my-account.php');


 $gClient = new Google_Client();

 $gClient->setApplicationName('Login to .com');
 $gClient->setClientId(GOOGLE_CLIENT_ID);
 $gClient->setClientSecret(GOOGLE_CLIENT_SECRET);
 $gClient->setRedirectUri(GOOGLE_REDIRECT_URL);
 $gClient->addScope('email');
 $gClient->addScope('profile');

 if(isset($_GET['code'])){ 

    $token = $gClient->fetchAccessTokenWithAuthCode($_GET['code']);

    if(!isset($token["error"])){

    $gClient->setAccessToken($token['access_token']);

    // getting profile information
    $google_oauth = new Google_Service_Oauth2($gClient);
    $google_account_info = $google_oauth->userinfo->get();

    // Storing data into database
    $oauth_uid = $google_account_info->id;
    $first_name = trim($google_account_info->givenName);
    $last_name = trim($google_account_info->familyName);
    $email = $google_account_info->email;
    $profile_pic = $google_account_info->picture;

    require_once(DOCUMENT_ROOT . '/demo/tutor-student/models/User.php');
    $user_obj = new User();

    
    $user_data = $user_obj->is_record_exist(['oauth_uid' => $oauth_uid,'email' => $email,'role_id'=> '3' ]);
    if(!empty($user_data)) {
        $_SESSION['id'] = $user_data['id'];
        $_SESSION['role'] = $user_data['role_name'];
        $_SESSION['role_id'] = $user_data['role_id'];
        $_SESSION['name'] = $user_data['first_name'];
        $_SESSION['last_name'] = $user_data['last_name'];
        $_SESSION['email'] = $user_data['email'];
        $_SESSION['is_login'] = true;
        header('Location: ' . filter_var(GOOGLE_REDIRECT_URL,FILTER_SANITIZE_URL)); 
        exit;
    } else {

        $data = [   'oauth_uid' => $oauth_uid,'first_name' => $first_name,'last_name' => $last_name,'image' => $profile_pic,'role_id' => 3 
            ];

        $last_id = $user_obj->save($data);
        if($last_id > 0 ){
            $getdata = ['id' => $last_id];
            $user_data = $user_obj->get_user($getdata);
            if(!empty($user_data)) {
                $_SESSION['id'] = $user_data['id'];
                $_SESSION['role'] = $user_data['role_name'];
                $_SESSION['role_id'] = $user_data['role_id'];
                $_SESSION['name'] = $user_data['first_name'];
                $_SESSION['last_name'] = $user_data['last_name'];
                $_SESSION['email'] = $user_data['email'];
                $_SESSION['is_login'] = true;
                header('Location: ' . filter_var(GOOGLE_REDIRECT_URL,FILTER_SANITIZE_URL)); 
                exit;
            }
        }

    }
}

}

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)

相关问答

依赖报错 idea导入项目后依赖报错,解决方案:https://blog....
错误1:代码生成器依赖和mybatis依赖冲突 启动项目时报错如下...
错误1:gradle项目控制台输出为乱码 # 解决方案:https://bl...
错误还原:在查询的过程中,传入的workType为0时,该条件不起...
报错如下,gcc版本太低 ^ server.c:5346:31: 错误:‘struct...