aboutsummaryrefslogtreecommitdiff
path: root/frontend/fb_connect.php
diff options
context:
space:
mode:
Diffstat (limited to 'frontend/fb_connect.php')
-rw-r--r--frontend/fb_connect.php61
1 files changed, 36 insertions, 25 deletions
diff --git a/frontend/fb_connect.php b/frontend/fb_connect.php
index 603f9b5..d5bf81b 100644
--- a/frontend/fb_connect.php
+++ b/frontend/fb_connect.php
@@ -15,14 +15,14 @@
GNU General Public License for more details.
You should have received a copy of the GNU General Public License along
with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-require 'facebook-platform/facebook.php';
require_once 'lib/include.php';
+require_once 'lib/facebook.php';
start_session (null, true);
$session->auth ('iflogged');
$message = '';
$auth = true;
@@ -34,25 +34,27 @@ if ($session->status['afterlogged'] != 'yes' ||
$message = _('You are using a guest account. You must register in order to do this.');
$auth = false;
}
else if ($link == '1')
{
try {
- $fb = new Facebook ($CONF['fb.api_key'], $CONF['fb.secret_key']);
- $fb_user = $fb->get_loggedin_user ();
- if ($fb_user) {
- $db = new Database ();
- $db->query ("UPDATE user SET fbUID=".$fb_user." WHERE id='".
- $session->id."'");
- }
- else {
- $fb->set_user (null, null);
+ $fb = new Facebook (array ('appId' => $CONF['fb.app_id'],
+ 'secret' => $CONF['fb.secret_key'],
+ 'cookie' => true));
+ $fb_session = $fb->getSession ();
+ if ($fb_session) {
+ $fb_uid = $fb->getUser ();
+ if ($fb_uid) {
+ $db = new Database ();
+ $db->query ("UPDATE user SET fbUID=".$fb_uid." WHERE id='".
+ $session->id."'");
+ }
}
}
- catch (Exception $e) {
- echo $e->getMessage ();
+ catch (FacebookApiException $e) {
+ error_log ($e);
}
}
else if ($link == '0')
{
$db->query ("UPDATE user SET fbUID=0 WHERE id='".$session->id."'");
}
@@ -62,18 +64,28 @@ if ($auth) {
$db = new Database ();
$db->query ("SELECT fbUID FROM user WHERE id='".$session->id."'");
if ($db->next_record ()) {
$fbUID = $db->f ('fbUID');
- $fb = new Facebook ($CONF['fb.api_key'], $CONF['fb.secret_key']);
- $fb_user = $fb->get_loggedin_user ();
- if ($fb_user) {
- $ud = $fb->api_client->users_getInfo ($fb_user, array ('profile_url'));
- if ($ud && isset ($ud[0]['profile_url']))
- $profile_url = $ud[0]['profile_url'];
+ try {
+ $fb = new Facebook (array ('appId' => $CONF['fb.app_id'],
+ 'secret' => $CONF['fb.secret_key'],
+ 'cookie' => true));
+ $fb_session = $fb->getSession ();
+ if ($fb_session) {
+ $fb_uid = $fb->getUser ();
+ if ($fb_uid) {
+ $me = $fb->api ('/me');
+ if ($me && isset ($me['link']))
+ $profile_url = $me['link'];
+ }
+ }
+ }
+ catch (FacebookApiException $e) {
+ error_log ($e);
}
}
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
@@ -105,23 +117,22 @@ if ($auth) {
else
echo $fbUID;
echo '</p>';
}
else {
echo '<p>Your account is not connected with Facebook</p>'."\n";
- echo '<p><fb:login-button length="long" background="light" size="medium" onlogin="fb_link()"></fb:login-button></p>'."\n";
+ echo '<p><fb:login-button length="long" onlogin="fb_link()" perms="email" /></p>'."\n";
}
?>
-<?php if (isset ($CONF['fb.api_key'])) { ?>
-<script type="text/javascript" src="http://static.ak.connect.facebook.com/js/api_lib/v0.4/FeatureLoader.js.php"></script>
+<?php if (isset ($CONF['fb.app_id'])) { ?>
+<div id="fb-root"></div>
+<script type="text/javascript" src="http://connect.facebook.net/en_US/all.js"></script>
<script type="text/javascript">
function fb_link () { window.location = 'fb_connect?link=1'; }
- FB_RequireFeatures (['XFBML'], function () {
- FB.init ('<?=$CONF["fb.api_key"]?>', 'xd_receiver.html',
- {'permsToRequestOnConnect': 'email'});
- });
+ FB.init ({appId: '<?=$CONF['fb.app_id']?>', status: true, cookie: true,
+ xfbml: true});
</script>
<?php } }?>
</body>
</html>

Return to:

Send suggestions and report system problems to the System administrator.