views:

5788

answers:

7

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"&gt;
  <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"&gt;&lt;/script&gt;
    <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!

+2  A: 

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. :)

Nick Lewis
Hi Nick,Thanks for the response. That's not the problem - I've done that already. I just didn't think it would be appropriate to display my application ID and application secret in this code.I appreciate the help though!
Mark
+5  A: 

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
Anurag
For mine, I had left off the 'www' in facebook, but my host auto-forwarded to www... so the urls were different
Dusty J
A: 

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"

Ji
Adelein Rodriguez, in your base domain, just specify ddailygirl.com
Ji
+1  A: 

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!!!

Neo302
A: 

I was having the same issue and realized from what Ji said it was because I had placed in my connect url www.ddailygirl.com but was testing from ddailygirl.com, which are different things.

Now the question is, how can I make it work for both with and without www? As it is my domain works with both, but not facebook connect.

Adelein Rodriguez
A: 

Thanks Anurag, I was having the same problem with my facebook connect. And I spent a whole day checking the code line by line. I just found this article and checked the Connect Url after seeing your answer. Other programmer have set the connect url with a wrong one. Just corrected and its working. Thanks again for you and stackoverflow.com.

Kasun
+1  A: 

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.

jenming
where do you see those settings?
fastmultiplication
http://www.facebook.com/developers/apps.phpClick on your application, then "edit settings"Click on "Web Site"
jenming
BUT, it seems they've changed their settings page!Click on "Web Site" - that has domain. But Connect URL seems to have disappeared....
jenming