Facebook OAuth no longer functioning
I had a script that was working perfectly up until a couple of hours ago. This script authorizes a user, checks to see if the user is logged in, and inserts data into my database. As of now, it fails to both identify a user or insert any data. Any help will be appreciated.
<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>";
?>
Have you checked to make you you have updated to Facebook's oAuth 2.0? All FB apps and apps using the FB api are required to upgrade to oAuth 2.0 by October 1st, 2011.
精彩评论