0

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?

Uffo
  • 9,628
  • 24
  • 90
  • 154
  • 1
    Login with the facebook account which has admin privileges over the app and see what error it shows. It should show some setting specific error. Also check that the URL you are redirecting to is set in website section (facebook will not redirect to any URL). Check you have set the domain and secure url correctly. – Ashwini Dhekane Feb 08 '12 at 15:32
  • You are going to have to include more information. How are you instantiating the Facebook SDK? What parameters are you feeding to the `getLoginUrl` method? – Lix Feb 08 '12 at 15:32
  • UPDATED! Please check my main post.Thank you! – Uffo Feb 08 '12 at 15:41

2 Answers2

5

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

Uffo
  • 9,628
  • 24
  • 90
  • 154
2

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

Shai Mishali
  • 9,224
  • 4
  • 56
  • 83