Facebook OAuth不再运作

时间:2011-10-10 01:11:33

标签: facebook-graph-api

我的脚本在几个小时前完美运行。此脚本授权用户,检查用户是否已登录,并将数据插入到我的数据库中。 截至目前,它无法识别用户或插入任何数据。任何帮助将不胜感激。

<style type="text/css">
  <!--
       #apDiv1 {
position:absolute;
width:200px;
height:198px;
z-index:1;
left: 757px;
top: 18px;
    }
       -->
      </style>
     <div id="apDiv1"><img src="../Downloads/tree06_small.png" width="188" height="250"     alt="" /></div>
    <?php
     require ("santatree/facebook.php");
       include('login.php');
       $facebook = new Facebook(array(
          'appId'  => 'id',
        'secret' => 'secret',
        ));


      $db_select=mysql_select_db($db_database); 
     if (!$db_select) 
     { 
     die ("Impossible Function". mysql_error());
       } 


     $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) {
    if ($user) {

     $token = $facebook->getAccessToken();
      $friends = $facebook->api('/me/friends');
       $friendsData = $friends['data'];

       $User = $user['data']; 
        for ($i = 0; $i < sizeof($friendsData); $i++)
    {
     $friend = $friendsData[$i];
       echo $friend['name'] . ", ";
      echo $friend['id']; 
        echo $user['id'];
       $sq1 = "INSERT into tbl_Friends (Name, FriendID, Access_ID) VALUES                  ('".$friend['name']."', '" .$friend['id']."', '".$user_profile['id']."')";
          error_log($e);
        $user = null;
            }
       }
         mysql_query($sq1); 

     }         
        $logoutUrl = $facebook->getLogoutUrl();


      } else {
        $loginUrl = $facebook->getLoginUrl();

    }

      $access_token = $_SESSION['fb_276853929000834_access_token'];
      if (!$access_token) {
      echo '<script>';
       echo 'top.location.href = "'.$loginUrl.'";';
         echo '</script>';
     } else {
         // ------ Create Drop Down Name List from Friends Table ------

        $myuserid = $user_profile['id'];
       echo "<html>";
         echo "<form enctype='multipart/form-data' method='post'       action='uploadpicture1.php' name='Giftgiver'>";
      $result= @mysql_query("select Friend_ID, tbl_Friends.Name from tbl_Friends inner              join tbl_Users on tbl_Friends.Access_ID=tbl_Users.Access_ID where tbl_Friends.Access_ID =         $myuserid"); 
      print "<p> Select a Friend: \n";
    print "<Select name=\"Friend_ID\">\n";
     while ($row=mysql_fetch_assoc($result)){
      $Friend_ID=$row['Friend_ID'];
     $Name =$row['Name'];
       print "<option value=$Friend_ID>$Name \n";
       }
          print "</select>\n";
         print "</p>\n";
        echo "Choose a gift!";
        echo "<input type='file' name='GiftChoice' value='1'>";

         }
         echo "</form>"; 
         echo "</html>";
          ?>

1 个答案:

答案 0 :(得分:0)

你有没有检查过你已经更新到Facebook的oAuth 2.0? 使用FB api的所有FB应用程序和应用程序都需要在2011年10月1日之前升级到oAuth 2.0。