2

I am new to the facebook api. I had written the following code after reading the fb developers documentation:

<?php

require_once("php-sdk/src/facebook.php");

$config = array();
$config[‘appId’] = '(my app id)';   //correct in actual code
$config[‘secret’] = '(my app secret)';  //correct in actual code
$config[‘fileUpload’] = false; // optional

$facebook = new Facebook($config);

$user=$facebook->getUser();

if($user==0)
{
$params = array(
'redirect_uri' => 'http://mydomain.com/facebook/php_index.php'
);

$login_url = $facebook->getLoginUrl($params);
echo $login_url."<br/><br/>";
echo '<div class="notice">You need to <a href="' . $login_url . '" onclick="top.location.href = \'' . $login_url . '\';">authenticate first</a>.</div>';
}
else
{
echo $user;
}

?>

The domain & url seetings are correct in fb apps page. But still on clicking the login link it shows An error occurred. Please try later.

Can somebody please help me out. thanks in advance.

  • If your domain is starts with ip address(192.176....) it wont work. Try it using live server url 'http://mydomain.com/' in browser. – Justin John Jun 09 '12 at 11:59
  • @Jusnit I am using free hosting on x10hosting. Its is mydomain.x10.mx –  Jun 09 '12 at 12:05
  • Sorry, then I don't know. I only want to say add only normal domains, but not localhost domains. In this case you are using sub-domain `sub.domain.com` would works – Justin John Jun 09 '12 at 12:21
  • Here is a similar question, check out the comments here - http://stackoverflow.com/questions/9196247/facebook-connect-an-error-occurred-please-try-again-later – David Jun 09 '12 at 16:28
  • What is your $login_url? What is the actual URL in the URL bar and what is the result of var_dump($login_url); ? – Xyz Jun 11 '12 at 21:50
  • Is it error 191? If it is, search it through stackoverflow and you will be fine. – alumi Jun 12 '12 at 04:17

1 Answers1

0

It seems that you didn't setup your preferences of your addon in the API. In my case I get this message if I had the wrong path, incorrect login URL and wrong domain in the application settings. Some description of Facebook can be found in their getting started guide

Edit: It is the canvas preference page. You have to choose the option above "Website" instead

Charley P.
  • 184
  • 1
  • 13
rokdd
  • 541
  • 4
  • 14
  • ok, yeah got it, had made a silly mistake. actually had shifted the code to a new url in the same domain. –  Jun 18 '12 at 18:49
  • @Charley P.: Thank your for your edit. I was not concentrated enough to avoid some mistakes :( – rokdd Jun 19 '12 at 12:17