【发布时间】:2024-05-18 05:25:01
【问题描述】:
*如果有兴趣,请查看 Foursquare 对此问题的回答,作为对这篇文章的评论*
请帮忙,我还在为此奋斗:(
我创建了一个删除所有 Foursquare 相关 cookie 的按钮。 使用 Firebug 进行检查,单击时未设置 cookie。
同样的编程删除插入数据库的令牌 当用户第一次登录时。在数据库中检查,该行是 已删除。
接下来会发生什么:
- 在没有 cookie 的全新浏览器中,用户登录。
- Cookie 已设置,并在其中插入带有令牌和用户 ID 的行 数据库。
- 用户退出。
未设置 Cookie 并从数据库中删除行
现在,另一个用户想要登录。他/她在我的网络应用程序中单击
<a href='".$authorizeUrl."'>Log in</a>。Foursquare 登录页面显示,但在他/她可以填写表格之前 在,页面使用以前的用户令牌重定向回我的网络应用程序 和信息!
在不发生第 6 点的情况下,我可以做一个干净的开始的唯一方法是 手动从我的浏览器中删除所有 cookie :(
任何想法都将不胜感激,我不知道该去哪里。 在我正在使用的代码下方,请尝试一下,您会看到第 6 步是如何发生的。
非常感谢
<?php
ob_start();
require_once('includes/EpiCurl.php');
require_once('includes/EpiSequence.php');
require_once('includes/EpiFoursquare.php');
$logout= $_GET['logout'];
if ($logout == 'true'){ /*I'm deleting all the cookies foursquare related just in case*/
$pastdate = mktime(0,0,0,1,1,1970);
setcookie ("XSESSIONID", "", time() - 18600);
setcookie ("access_token", "", time() - 18600);
setcookie ("ext_id", "", time() - 18600);
setcookie ("LOCATION", "", time() - 18600);
setcookie("access_token", "", $pastdate);
setcookie("XSESSIONID", "", $pastdate);
setcookie("ext_id", "", $pastdate);
setcookie("LOCATION", "", $pastdate);
setcookie("_chartbeat2", "", $pastdate);
setcookie("__utmb", "", $pastdate);
setcookie("__utmc", "", $pastdate);
setcookie("__utma", "", $pastdate);
setcookie("__utmz", "", $pastdate);
$_SESSION['XSESSIONID']=false;
unset($_SESSION['XSESSIONID']);
}
$clientId = "yyyyyyyyy";
$clientSecret = "xxxxx";
$redirectUrl = 'mypage.php';
$fsObjUnAuth = new EpiFoursquare($clientId, $clientSecret);
$thecode = $_GET['code'];
if(!isset($thecode) && !isset($_COOKIE['access_token'])) { //not in yet
$authorizeUrl = $fsObjUnAuth->getAuthorizeUrl($redirectUrl);
echo"<a href='".$authorizeUrl."'>Let's log in</a>";
}else{ /*we're in*/
if(!isset($_COOKIE['access_token'])) {
$token = $fsObjUnAuth->getAccessToken($thecode, $redirectUrl);
setcookie('access_token', $token->access_token);
$_COOKIE['access_token'] = $token->access_token;
}
$fsObjUnAuth->setAccessToken($_COOKIE['access_token']);
echo "we're in";
echo"<br><a href='mypage.php?logout=true'>Logout</a>";
}
?>
【问题讨论】:
-
目前我们还没有准备好允许第三方应用程序将用户从foursquare.com 中注销。如果您认为退出您的应用程序的用户应该退出foursquare.com,我们建议在您的退出页面上放置一个醒目的号召性用语(例如“退出foursquare!”)。 ~ak --
-
我遇到了这个问题,我正在使用 Foursquare API,如果我登录 myapp 然后我想搜索 Fourquare 信息,但如果在网络浏览器中登录其他用户在 Fourquare 中,我的搜索结果是来自活动帐户的信息(不是我的信息),我该如何控制?
标签: php button oauth logout foursquare