duanjiangzhi6851 2019-06-21 17:42
浏览 191

在Wordpress登录重定向后问题

i have a website with this URL https://en.economarks.com/ the website is build with WordPress the main thing is to check if user is logged in to his face book account and if not a button will display to connect to face book .

i have created a php page inside the them by the name formReg

<?php

session_start();
require 'vendor/autoload.php';

$fb = new \Facebook\Facebook([
    'app_id' => '65656565655665',
    'app_secret' => '????????????????',
    'default_graph_version' => 'v2.7'
]);

$helper = $fb->getRedirectLoginHelper();
$login_url = $helper->getLoginUrl("https://en.economarks.com/wp-content/themes/twentyseventeen/FormReg.php");


try {
    $accessToken = $helper->getAccessToken();

    if(isset($accessToken)){
        $_SESSION['token'] = (string)$accessToken;
        header("Location:https://en.economarks.com/form");
    }
} catch (Exception $exc){
        $exc->getTraceAsString();
}

echo $_SESSION['token'];
if(isset($_SESSION['token'])){
    try
    {
        $fb->setDefaultAccessToken($_SESSION['token']);
        $res = $fb->get('/me?fields=name,email,location,gender,birthday,hometown', $_SESSION['token']);
        $user = $res->getGraphUser();
         echo  $user->getField('name');
        $id =   $user->getField('id');
        echo   $user->getField('email');
        $picter = "https://graph.facebook.com/".$id."/picture?type=large&width=720&height=720";
        echo $useremail = $user->getField('email');

    } catch (Exception $exc){
        $exc->getTraceAsString();
    }


}

?>



            <?php if(isset($_SESSION['token'])) : ?>

            <?php else : ?>
                <a href="<?= $login_url ?>">Login With FaceBook</a>
            <?php endif; ?>
            <br>
            <img style="width: 50px" src="<?= $picter ?>">

the code is working fine when i test is outside WordPress . my problem is after the log in is complicate the page redirect that i want is https://en.economarks.com/form but i don't get the user data and i am still not logged in but when i redirect to https://en.economarks.com/wp-content/themes/twentyseventeen/FormReg.php every thing is working fine any help?

</div>
  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 神经网络预测均方误差很小 但是图像上看着差别太大
    • ¥15 Oracle中如何从clob类型截取特定字符串后面的字符
    • ¥15 想通过pywinauto自动电机应用程序按钮,但是找不到应用程序按钮信息
    • ¥15 如何在炒股软件中,爬到我想看的日k线
    • ¥15 seatunnel 怎么配置Elasticsearch
    • ¥15 PSCAD安装问题 ERROR: Visual Studio 2013, 2015, 2017 or 2019 is not found in the system.
    • ¥15 (标签-MATLAB|关键词-多址)
    • ¥15 关于#MATLAB#的问题,如何解决?(相关搜索:信噪比,系统容量)
    • ¥500 52810做蓝牙接受端
    • ¥15 基于PLC的三轴机械手程序