这是一个我认为值得了解并且对其他人有用的问题,因为我认为很多人都喜欢那些花式框和灯箱弹出窗口,而不是你通常会得到的普通窗口弹出窗口。
我问一个问题,如果可以将twitter身份验证放在fancybox / lightbox中,那么一旦用户点击使用Twitter登录按钮,它就会在一个漂亮的fancybox中打开甚至是灯箱?
我通过google和stackoverflow进行了一些搜索,我找不到任何有助于回答此问题的相关信息?
所以目前我现在有了这个页面https://www.tubenations.com/twitter.php(请注意,除非您有帐户并且已登录,否则此链接无效!)
我已经在我的网站上安装了fancybox用于其他元素,但我认为如果可以将twitter auth屏幕放入fancybox中它会更好看吗?
所以我的twitter.php页面上的当前设置如下
<hr>
<div class="twitterInfo2">In order for you to view and appear on this page you need to authenticate your twitter account by clicking sign in with twitter button below!
<br />
</div>
<br />
<a href="/twitter/process.php">
<img class="twitterImage" src="/twitter/images/sign-in-with-twitter.png" title="Tube Nations Link Your Twitter" alt="Tube Nations Link Your Twitter" />
</a>
<hr>
所以基本上是 /twitter/process.php 文件完成了工作,我也会发布process.php文件的代码,因为我也认为该文件需要调整如果可能的话,使用fancybox包含代码?
if(isset($_REQUEST['oauth_token']) && $_SESSION['token'] !== $_REQUEST['oauth_token']) {
//If token is old, distroy session and redirect user to index.php
session_destroy();
header('Location: index.php');
}elseif(isset($_REQUEST['oauth_token']) && $_SESSION['token'] == $_REQUEST['oauth_token']) {
//Successful response returns oauth_token, oauth_token_secret, user_id, and screen_name
$connection = new TwitterOAuth(CONSUMER_KEY, CONSUMER_SECRET, $_SESSION['token'] , $_SESSION['token_secret']);
$access_token = $connection->getAccessToken($_REQUEST['oauth_verifier']);
include_once("../inc/header_session.php");
if($connection->http_code == '200' && $tn_userid != 1)
{
//Redirect user to twitter
$_SESSION['status'] = 'verified';
$_SESSION['request_vars'] = $access_token;
//Insert user into the database
$user_info = $connection->get('account/verify_credentials');
$name = explode(" ",$user_info->name);
$fname = isset($name[0])?$name[0]:'';
$lname = isset($name[1])?$name[1]:'';
$db_user = new Users();
$db_user->checkUsers('twitter',$user_info->id,$user_info->screen_name,$fname,$lname,$user_info->lang,$access_token['oauth_token'],$access_token['oauth_token_secret'],$user_info->profile_image_url,$user->data['user_id']);
//Unset no longer needed request tokens
unset($_SESSION['token']);
unset($_SESSION['token_secret']);
header('Location: /twitter.php');
}else{
die("error, try again later!");
} }
}else{
if(isset($_GET["denied"]))
{
header('Location: /twitter.php');
die();
}
//Fresh authentication
$connection = new TwitterOAuth(CONSUMER_KEY, CONSUMER_SECRET);
$request_token = $connection->getRequestToken(OAUTH_CALLBACK);
//Received token info from twitter
$_SESSION['token'] = $request_token['oauth_token'];
$_SESSION['token_secret'] = $request_token['oauth_token_secret'];
//Any value other than 200 is failure, so continue only if http code is 200
if($connection->http_code == '200')
{
//redirect user to twitter
$twitter_url = $connection->getAuthorizeURL($request_token['oauth_token']);
header('Location: ' . $twitter_url);
}else{
die("error connecting to twitter! try again later!");
}}
我希望有可能吗?