2010-06-14 92 views
1

當我得到這個錯誤,當我點擊Facebook的連接按鈕:Facebook連接:錯誤點擊Facebook連接按鈕

API Error Code: 100 
API Error Description: Invalid parameter 
Error Message: next is not owned by the application. 

我也不太清楚如何做到這一點,但我讀過的所有對於Facebook的文檔連接並想出了這一點:

<?php 
date_default_timezone_set("America/Toronto"); 

define('FACEBOOK_APP_ID', '##################'); 
define('FACEBOOK_SECRET', 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXX'); 

function get_facebook_cookie($app_id, $application_secret) { 
    if(!isset($_COOKIE['fbs_' . $app_id])) return null; 
    $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); 


?> 
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:fb="http://www.facebook.com/2008/fbml"> 
    <head> 
     <!-- JQUERY INCLUDE --> 
     <script src="js/jquery-1.4.2.min.js" type="text/javascript"></script> 

     <!-- FACEBOOK CONNECT INCLUDE --> 
     <script src="http://static.ak.connect.facebook.com/js/api_lib/v0.4/FeatureLoader.js.php/en_US" type="text/javascript"></script> 

     <script type="text/javascript"> 
     <!-- 
      $(document).load(function() { 

      }); 

      FB.init("XXXXXXXXXXXXXXXXXXXXXXx 

」, 「xd_receiver.htm」); FB.Event.subscribe( 'auth.login',功能(響應){ window.location的。 reload(); });

  function facebook_onlogin() { 
       FB.getLoginStatus(function(response) { 
        if (response.session) { 
         // logged in and connected user, someone you know 
         fb_login.hide(); 
        } else { 
         // no user session available, someone you dont know 

        } 
       }); 
      } 

     // --> 
     </script> 

    </head> 

    <body>  
     <div id="fb_login"> 
      <fb:login-button onlogin="facebook_onlogin();" v="2">Log In with Facebook</fb:login-button> 
     </div> 

     <?php 
     $user = json_decode(file_get_contents(
      'https://graph.facebook.com/me?access_token=' . 
      $cookie['access_token']))->id; 

     ?> 

    </body> 
</html> 

我怎麼能得到這個工作?

謝謝!

回答

1

該錯誤看起來像是試圖說你的連接URL與頁面所在的位置不匹配。

+0

這將是有道理的,因爲我在調試,但我已經將其設置爲http://127.0.0.1:9000/ 是不是我應該爲它做本地測試? – Garrett 2010-06-16 02:56:59