亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

谷歌登錄不重定向到在線服務器上的特定 PHP 頁面

谷歌登錄不重定向到在線服務器上的特定 PHP 頁面

PHP
慕標琳琳 2023-03-26 16:14:00
這是我的 PHP Google 登錄腳本。它在本地主機上工作,但是當我把它放在在線服務器上時它不工作。我想重定向特定頁面但不重定向。身份驗證后顯示 HTTP ERROR 500。解決方案是什么?在本地主機上它的工作順利。但在在線服務器中顯示 HTTP ERROR 500。為什么?authenticate.php<?php require_once 'config.php';if(isset($_GET['code'])){    $googleClient->authenticate($_GET['code']);    $_SESSION['token'] = $googleClient->getAccessToken();    header('Location: ' . filter_var($redirectURL, FILTER_SANITIZE_URL));}############ Set Google access token ############if (isset($_SESSION['token'])) {    $googleClient->setAccessToken($_SESSION['token']);}if ($googleClient->getAccessToken()) {    ############ Fetch data from graph api  ############    try {        $gpUserProfile = $google_oauthV2->userinfo->get();    }    catch (\Exception $e) {        echo 'Graph returned an error: ' . $e->getMessage();        session_destroy();        header("Location: ./");        exit;    }    ############ Store data in database  ############    $oauthpro = "google";    $oauthid = $gpUserProfile['id'] ?? '';    $first_name = $gpUserProfile['given_name'] ?? '';    $last_name = $gpUserProfile['family_name'];    $email_id = $gpUserProfile['email'] ?? '';    $picture = $gpUserProfile['picture'] ?? '';    $sql = "SELECT * FROM users WHERE oauthid='".$gpUserProfile['id']."'";    $result = $conn->query($sql);    if ($result->num_rows == 1) {       $conn->query("UPDATE users SET first_name='".$first_name."', last_name='".$last_name."', email_id='".$email_id."', picture='".$picture."' where oauthid='".$oauthid."' ");    } else {        $conn->query("INSERT INTO users (oauth_pro, oauthid, first_name, last_name, email_id, picture) VALUES ('".$oauthpro."', '".$oauthid."', '".$first_name."', '".$last_name."', '".$email_id."', '".$picture."')");      }    $res = $conn->query($sql);    $Loggedin = $res->fetch_assoc();    $_SESSION['Loggedin'] = $Loggedin;    header("Location: ../../study.php");} else {    header("Location:/");}
查看完整描述

1 回答

?
瀟瀟雨雨

TA貢獻1833條經驗 獲得超4個贊

是的!我得到了答案。

當我使用 (.cf) 域或任何其他免費域或免費托管時,它無法在在線服務器上運行。但是,當我嘗試使用付費頂級域并托管時,它可以正常工作。


查看完整回答
反對 回復 2023-03-26
  • 1 回答
  • 0 關注
  • 133 瀏覽

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號