Uffo
Uffo

Reputation: 10046

Facebook connect "An error occurred. Please try again later."

I have a link on my page and the links has the href set by this $facebook->getLoginUrl(); when I click on the link and go to facebook I get this error: An error occurred. Please try again later. :| ? Any help? Thanks!

<?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();
    }
}

What I do in my action controller, I pass this $this->getHelper('FbData')->fbLoginUrl(); to the view, what this does it return the facebook login url, so when the user clicks on the link, it redirect's it to facebook, and after that I want to be redirected back to my page so I can log the user in, is my whole concept wrong?

Upvotes: 0

Views: 8241

Answers (2)

Shai Mishali
Shai Mishali

Reputation: 9382

Just an addition to this question - This could also happen if your app is accidentally left in "Sandbox Mode".

Upvotes: 2

Uffo
Uffo

Reputation: 10046

The problem was caused because I had other url set on facebook for the site that the one that I was trying to login.

Upvotes: 5

Related Questions