summaryrefslogtreecommitdiffabout
authorWojciech Polak <polak@gnu.org>2010-04-28 16:57:27 (GMT)
committer Wojciech Polak <polak@gnu.org>2010-04-28 16:57:27 (GMT)
commitf0cb1cdb39370971010723ab4f7f5a95f845eca6 (patch) (side-by-side diff)
tree4058dd9deaf80eca3aed529ab57eca90d06080bc
parent2dba4fd46dbaece7a6e5e9a67bd41f1fd8a01560 (diff)
downloadcheetah-f0cb1cdb39370971010723ab4f7f5a95f845eca6.tar.gz
cheetah-f0cb1cdb39370971010723ab4f7f5a95f845eca6.tar.bz2
Switch to new FB API.
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--.gitignore2
-rw-r--r--frontend/fb_connect.php61
-rw-r--r--frontend/lib/config-sample.php1
-rw-r--r--frontend/lib/session.class.php7
-rw-r--r--frontend/login.php39
-rw-r--r--frontend/reader.php7
-rw-r--r--js/v2/boot.js5
-rw-r--r--js/v2/gui.js6
8 files changed, 70 insertions, 58 deletions
diff --git a/.gitignore b/.gitignore
index 9a0ae5e..d5db7f9 100644
--- a/.gitignore
+++ b/.gitignore
@@ -6,5 +6,5 @@
errorlog
-frontend/facebook-platform/
frontend/lib/config.php
frontend/lib/d-sigs.php
+frontend/lib/facebook.php
frontend/trs/*
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
@@ -20,4 +20,4 @@
-require 'facebook-platform/facebook.php';
require_once 'lib/include.php';
+require_once 'lib/facebook.php';
@@ -39,15 +39,17 @@ 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);
}
@@ -67,8 +69,18 @@ if ($auth) {
- $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);
}
@@ -110,3 +122,3 @@ if ($auth) {
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";
}
@@ -114,10 +126,9 @@ if ($auth) {
-<?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>
diff --git a/frontend/lib/config-sample.php b/frontend/lib/config-sample.php
index f4ff687..1be1afd 100644
--- a/frontend/lib/config-sample.php
+++ b/frontend/lib/config-sample.php
@@ -29,3 +29,2 @@ $CONF['google.analytics'] = 'GA-CODE';
$CONF['fb.app_id'] = 'FACEBOOK-APP-ID';
-$CONF['fb.api_key'] = 'FACEBOOK-API-KEY';
$CONF['fb.secret_key'] = 'FACEBOOK-SECRET-KEY';
diff --git a/frontend/lib/session.class.php b/frontend/lib/session.class.php
index 8a18f18..b1f7208 100644
--- a/frontend/lib/session.class.php
+++ b/frontend/lib/session.class.php
@@ -277,6 +277,5 @@ class Session
{
- $user_details = $fb->api_client->users_getInfo ($fb_uid,
- array ('email'));
- if ($user_details && isset ($user_details[0]['email']))
- $email = $user_details[0]['email'];
+ $me = $fb->api ('/me');
+ if ($me && isset ($me['email']))
+ $email = $me['email'];
else
diff --git a/frontend/login.php b/frontend/login.php
index bce0377..a864280 100644
--- a/frontend/login.php
+++ b/frontend/login.php
@@ -79,14 +79,16 @@ if (isset ($_GET['openid_mode']) && !empty ($_GET['openid_mode']))
}
-else if ($fbConnect && isset ($CONF['fb.api_key']) &&
+else if ($fbConnect && isset ($CONF['fb.app_id']) &&
isset ($CONF['fb.secret_key'])) {
- require 'facebook-platform/facebook.php';
- $fb = new Facebook ($CONF['fb.api_key'], $CONF['fb.secret_key']);
- $fb_uid = $fb->get_loggedin_user ();
- if ($fb_uid) {
- $insideFB = $fb_sig_in_iframe == '1' ? true : false;
- $message = $_SESSION['session']->fb_login ($fb, $fb_uid, $insideFB,
- $feedurl);
- }
- else {
- $fb->set_user (null, null);
+ require 'lib/facebook.php';
+ $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) {
+ $insideFB = $fb_sig_in_iframe == '1' ? true : false;
+ $message = $_SESSION['session']->fb_login ($fb, $fb_uid, $insideFB,
+ $feedurl);
+ }
}
@@ -207,3 +209,3 @@ echo '<html xmlns="http://www.w3.org/1999/xhtml"
<td align="left">
- <fb:login-button length="long" background="light" size="medium" onlogin="fb_login()"></fb:login-button>
+ <fb:login-button length="long" onlogin="fb_login()" perms="email" />
</td>
@@ -267,3 +269,3 @@ echo '<html xmlns="http://www.w3.org/1999/xhtml"
var addthis_brand = 'Cheetah News';
- var addthis_options = 'favorites,email,delicious,twitter,facebook,friendfeed,google,digg,reddit,more';
+ var addthis_options = 'delicious,twitter,facebook,friendfeed,googlebuzz,google,stumbleupon,digg,reddit,more';
</script>
@@ -359,9 +361,8 @@ if ($message)
-<?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">
-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>
diff --git a/frontend/reader.php b/frontend/reader.php
index 370895b..37a2dea 100644
--- a/frontend/reader.php
+++ b/frontend/reader.php
@@ -357,6 +357,7 @@ var SIGS = {'js':'".$SIGS["js"]."', 'tr':'".$SIGS["tr"]."', 'wt':'".
-<?php if (isset ($CONF['fb.api_key'])) { ?>
-<script type="text/javascript">CONF.fb_api_key = '<?=$CONF["fb.api_key"]?>';</script>
+<?php if (isset ($CONF['fb.app_id'])) { ?>
+<script type="text/javascript">CONF.fb_app_id = '<?=$CONF["fb.app_id"]?>';</script>
+<div id="fb-root"></div>
<div id="fbFanbox" style="display:none">
- <fb:fan profile_id="<?=$CONF['fb.app_id']?>" stream="0" connections="10" logobar="1" width="500" height="300"></fb:fan>
+ <iframe src="http://www.facebook.com/plugins/fan.php?id=<?=$CONF['fb.app_id']?>&amp;width=500&amp;height=300&amp;connections=10&amp;stream=false&amp;header=false" scrolling="no" frameborder="0" allowTransparency="true" style="border:none; overflow:hidden; width:500px; height:300px"></iframe>
</div>
diff --git a/js/v2/boot.js b/js/v2/boot.js
index 4f4f38e..a2d80b8 100644
--- a/js/v2/boot.js
+++ b/js/v2/boot.js
@@ -83,4 +83,5 @@ function dsp (res, p) {
function load_fb () {
- $.getScript ('http://static.ak.connect.facebook.com/js/api_lib/v0.4/FeatureLoader.js.php',
- function () { FB.init (CONF.fb_api_key, 'xd_receiver.html'); });
+ $.getScript ('http://connect.facebook.net/en_US/all.js', function () {
+ FB.init ({appId: CONF.fb_app_id, status: true});
+ });
}
diff --git a/js/v2/gui.js b/js/v2/gui.js
index df9e7b4..bcab5ce 100644
--- a/js/v2/gui.js
+++ b/js/v2/gui.js
@@ -349,5 +349,5 @@ function initMenu () {
if (confirm (_('Log out also from Facebook?'))) {
- FB.Connect.get_status ().waitUntilReady (function (status) {
- if (status == FB.ConnectState.connected)
- FB.Connect.logoutAndRedirect ('logout');
+ FB.getLoginStatus (function (res) {
+ if (res.session)
+ FB.logout (function (r) { window.location = 'logout'; });
else

Return to:

Send suggestions and report system problems to the System administrator.