我的页面上有一个链接,当我点击链接并转到facebook时,链接有$facebook->getLoginUrl();
设置的href我收到此错误:An error occurred. Please try again later.
:| ?有帮助吗?谢谢!
<?php
class iM_Action_Helper_FbData extends Zend_Controller_Action_Helper_Abstract
{
public function direct(array $params = array())
{
return true;
}
/*
* Connecting to facebook
* It connects to facebook, this is used when you need to log a user out,
* or if you want to get some data about a user which uses facebook
* @return OBJ
*/
public function fbConnect()
{
$getFB = Zend_Registry::get('FB');
$facebook = new Facebook(array(
'appId' => $getFB->FB->APPID,
'secret' => $getFB->FB->SECRET,
'cookie' => true
));
return $facebook;
}
/*
* Checks to see if a user is loggedin
* @param string $redirect
*/
public function checkIfLogged($redirect = "/")
{
$fbLogin = new Zend_Session_Namespace('fbLogin'); #Get Facebook Session
if(!$fbLogin->user) $this->getActionController()->getHelper('redirector')->gotoUrl($redirect); #Logout the user
}
public function fbLoginUrl()
{
$facebook = $this->fbConnect();
return $facebook->getLoginUrl();
}
}
我在动作控制器中执行的操作,我将此$this->getHelper('FbData')->fbLoginUrl();
传递给视图,这会返回facebook登录网址,因此当用户点击该链接时,它会将其重定向到facebook,之后我希望被重定向回我的页面,以便我可以登录用户,我的整个概念是错误的吗?
答案 0 :(得分:5)
问题的原因是因为我在Facebook上设置了我尝试登录的网站上的其他网址。
答案 1 :(得分:2)
只是这个问题的补充 - 如果你的应用程序意外地留在“沙盒模式”中,也会发生这种情况。