0

从昨天开始,我的网站在尝试登录网站时从 facebook 服务器端收到 500 服务器错误,我确定我没有更新我的代码,我搜索了所有内容,但没有找到任何解决方案。请检查我的代码并帮助我。

<?php
session_start();
require 'config/fbconfig.php';
require 'facebook/facebook.php';
include"core.php";
connectdb();

$facebook = new Facebook(array(
            'appId' => APP_ID,
            'secret' => APP_SECRET,
            ));


    $user = $facebook->getUser();


if ($user) {
  try {
    // Proceed knowing you have a logged in user who's authenticated.
    $user_profile = $facebook->api('/me');
  } catch (FacebookApiException $e) {
    error_log($e);
    $user = null;
  }






    if (!empty($user_profile )) {
        # User info ok? Let's print it (Here we will be adding the login and registering routines)

        $username = $user_profile['name'];
             $uid2 = $user_profile['id'];
         $email = $user_profile['email'];
         $validated = mysql_fetch_array(mysql_query("SELECT COUNT(*) FROM users WHERE email='".$email."'"));
       if($validated[0]== 1){
           $get_data = mysql_fetch_array(mysql_query("SELECT * FROM users WHERE email='".$email."'"));
           $visits = $get_data['visits'];
           $visits2 = $get_data['visits']+1;
           $sid= keygen(30);
           mysql_query("UPDATE users SET fbid='".$uid2."', visits= '".$visits2."', sid='".$sid."' WHERE email='".$email."'");


           $_SESSION['sid'] = $sid;
           $expire=time()+60*60*24*30;
           setcookie("sid", $_SESSION['sid'], $expire); 

           if($get_data['cat_sec']==0){
              header('Location: cat_select.php');
               exit();

           }else{
               if(isset($_SESSION['curl'])){
                header('Location:'.$_SESSION['curl']); 
             }else{
               header('Location: index.php');
             }
               exit();

           }
       }else{
         $sid= keygen(30);
         $register = mysql_query("INSERT INTO users SET fname='".$username."', email='".$email."', fbid='".$uid2."', active='1' , sid='".$sid."'");  

           include_once"reg_fb_mail.php";
           header('Location: cat_select.php');
               exit();

       }

        $permissions = $facebook->api("/me/permissions");
    if (array_key_exists('publish_stream', $permissions['data'][0])) {

        $attachment = array(
    'message' => 'my web site message',
    'name' => 'www.mywebsite.com!',
    'caption' => "caption.",
    'link' => 'http://www.website.com',
    'description' => 'website description gose here ',
    'picture' => 'http://website.com/images/fb.png',
    'actions' => array(
        array(
            'name' => 'www.website.com',
            'link' => 'http://www.website.com'
        )
    )
);


$result = $facebook->api('/me/feed/', 'post', $attachment);
} 

    } else {
        # For testing purposes, if there was an error, let's kill the script
        die("There was an error.");
    }
} else {
    # There's no active session, let's generate one
    $login_url = $facebook->getLoginUrl(array( 'scope' => 'email,publish_stream'));
    header("Location: " . $login_url);
}
?>

我已附上所有代码。请帮我解决这个问题。谢谢你。

4

1 回答 1

0

错误计算!问题不在于此代码。在 facebook 设置页面中,我发现 APP ID 之前有一个空格。它现在已修复.. Facebook dosent 从身份验证中的获取参数中修剪或删除空格。如果存在无效字符,则会在 facebook 中收到 500 服务器错误。我认为这是一个关键的安全问题。Hal Rotholz - 谢谢你的线索..

于 2013-03-28T00:13:05.090 回答