9
votes

I am trying to experiment with the new facebook authentication system, and I can't getthe login to work.

I'm getting the following error message:


API Error Code: 100

API Error Description: Invalid parameter

Error Message: next is not owned by the application.


The url that is being sent to facebook is:

http://www.facebook.com/connect/uiserver.php?app_id=444444444444444&next=http%3A%2F%2Fstatic.ak.fbcdn.net%2Fconnect%2Fxd_proxy.php%23%3F%3D%26cb%3Df357eceb0361a8a%26origin%3Dhttp%253A%252F%252Fwww.mysite.com%252Ff38fea4f9ea573%26relation%3Dopener%26transport%3Dpostmessage%26frame%3Df23b800f8a78%26result%3DxxRESULTTOKENxx&display=popup&channel=http%3A%2F%2Fwww.mysite.com%2Ffbtester.php&cancel=http%3A%2F%2Fstatic.ak.fbcdn.net%2Fconnect%2Fxd_proxy.php%23%3F%3D%26cb%3Df6095a98598be8%26origin%3Dhttp%253A%252F%252Fwww.mysite.com%252Ff38fea4f9ea573%26relation%3Dopener%26transport%3Dpostmessage%26frame%3Df23b800f8a78%26result%3DxxRESULTTOKENxx&locale=en_US&return_session=1&session_version=3&fbconnect=1&canvas=0&legacy_return=1&method=permissions.request

Note that the 'Next' variable in the url is:

next=http%3A%2F%2Fstatic.ak.fbcdn.net%2Fconnect%2Fxd_proxy.php%23%3F%3D%26cb%3Df357eceb0361a8a%26origin%3Dhttp%253A%252F%252Fwww.mysite.com%252Ff38fea4f9ea573%26relation%3Dopener%26transport%3Dpostmessage%26frame%3Df23b800f8a78%26result%3DxxRESULTTOKENxx


Any ideas what could be going wrong? All I've done is copy and paste the facebook login demo code from facebook's website:


 <?php
define('FACEBOOK_APP_ID', 'your application id');
define('FACEBOOK_SECRET', 'your application secret');

function get_facebook_cookie($app_id, $application_secret) {
  $args = array();
  parse_str(trim($_COOKIE['fbs_' . $app_id], '\\"'), $args);
  ksort($args);
  $payload = '';
  foreach ($args as $key => $value) {
    if ($key != 'sig') {
      $payload .= $key . '=' . $value;
    }
  }
  if (md5($payload . $application_secret) != $args['sig']) {
    return null;
  }
  return $args;
}

$cookie = get_facebook_cookie(FACEBOOK_APP_ID, FACEBOOK_SECRET);

?>


<!DOCTYPE html>
 <html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:fb="http://www.facebook.com/2008/fbml">
  <body>
    <?php if ($cookie) { ?>
      Your user ID is <?= $cookie['uid'] ?>
    <?php } else { ?>
      <fb:login-button></fb:login-button>
    <?php } ?>

    <div id="fb-root"></div>
    <script src="http://connect.facebook.net/en_US/all.js"></script>
    <script>
      FB.init({appId: '<?= FACEBOOK_APP_ID ?>', status: true,
               cookie: true, xfbml: true});
      FB.Event.subscribe('auth.login', function(response) {
        window.location.reload();
      });
    </script>
  </body>
 </html>

Thanks for the help!

5
Please use the correct formatting in your question, this is completely unreadable.Rabbott
Sorry about that...I've been having some trouble getting it to format correctly..Mark

5 Answers

5
votes

I was getting the same error, but I am using Rails and the problem was the Connect URL was not updated. My local application is running on port 3000, and the Connect URL was pointing at port 80.

See if changing that works for you.

  1. Goto http://www.facebook.com/developers
  2. Edit the application you are working on
  3. Click the Connect tab on the left
  4. Verify if Connect URL is setup correctly
1
votes

I don't know much about the Facebook API, but I do know that you have to actually replace the text your application id and your application secret with your application ID and your application secret. :)

1
votes

I had the same problem and couldn't figure it out. It was the base domain as Ji said. I would voted up, but I just joined. Requirements in FB setting pages are so bad... I used localhost.

I also used a querystring of ?nothing=1 for testing b/c of the new requirement where it says: connect url must point to a directory (i.e., end with a "/") or a dynamic page (i.e., have a "?" somewhere.

Therefore, you can't just put default.aspx. You have to end with a slash or have a ? which is a weird requirement for connect.

Thanks Ji!!!

1
votes

I was able to get this solved with these settings:

Base Domain: domain.com (this should also solve adelein's issues with multiple subdomains)

Connect URL: needs to be a valid http:// or https:// URL with a slash at the end OR a '?' somewhere in the URL, signifying a query string. Basically, facebook doesn't want you sending people to static pages which don't properly process the authorization they set up, i guess.

0
votes

if connect url is correct, and it still doesn't work, go to your app setting, specify a correct base domain. For testing, you can use localhost. If still no luck, go to migration setting, disable "new data permission"