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
@@ -4,9 +4,9 @@
*.so
.htaccess
errorlog
-frontend/facebook-platform/
frontend/lib/config.php
frontend/lib/d-sigs.php
+frontend/lib/facebook.php
frontend/trs/*
gen/popular.xml
po/*-js.po
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
@@ -18,8 +18,8 @@
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');
@@ -37,19 +37,21 @@ if ($session->status['afterlogged'] != 'yes' ||
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')
@@ -65,12 +67,22 @@ if ($auth) {
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);
}
}
}
@@ -108,18 +120,17 @@ if ($auth) {
}
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 } }?>
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
@@ -27,7 +27,6 @@ $CONF['google.mapkey'] = 'GOOGLE-MAP-KEY';
$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';
$CONF['whatsnew'] = false;
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
@@ -275,10 +275,9 @@ class Session
}
else
{
- $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
return _('E-mail address is required.');
diff --git a/frontend/login.php b/frontend/login.php
index bce0377..a864280 100644
--- a/frontend/login.php
+++ b/frontend/login.php
@@ -77,18 +77,20 @@ if (isset ($_GET['openid_mode']) && !empty ($_GET['openid_mode']))
$email);
}
}
-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);
+ }
}
}
else if ($SignIn)
@@ -205,7 +207,7 @@ echo '<html xmlns="http://www.w3.org/1999/xhtml"
<tr id="trFBConnect">
<td align="right"><?php echo 'Facebook: '; ?></td>
<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>
</tr>
<tr>
@@ -265,7 +267,7 @@ echo '<html xmlns="http://www.w3.org/1999/xhtml"
var addthis_logo_background = 'ffffff';
var addthis_logo_color = '666699';
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>
<a href="http://www.addthis.com/bookmark.php?v=20" onmouseover="return addthis_open(this, '', 'http://www.cheetah-news.com/', 'Cheetah News -- Web-based Personal News Aggregator')" onmouseout="addthis_close()" onclick="return addthis_sendto()"><img src="images/share.png" width="83" height="16" alt="Bookmark and Share" style="border-style:none" /></a>
<?php if (isset ($_SERVER['HTTPS'])) { ?>
@@ -357,13 +359,12 @@ if ($message)
</div>
-<?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>
<?php } ?>
diff --git a/frontend/reader.php b/frontend/reader.php
index 370895b..37a2dea 100644
--- a/frontend/reader.php
+++ b/frontend/reader.php
@@ -355,10 +355,11 @@ var SIGS = {'js':'".$SIGS["js"]."', 'tr':'".$SIGS["tr"]."', 'wt':'".
<hr /><span id="logout" class="linkCM">&nbsp;<img src="images/t.gif" width="16" height="16" alt="" /></span>
</div>
-<?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>
<?php } ?>
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
@@ -81,8 +81,9 @@ 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});
+ });
}
setTimeout (load_fb, 2500);
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
@@ -347,9 +347,9 @@ function initMenu () {
setCmhLink (GID ('logout'), function () {
if (cheetahData.fbUID && typeof FB != 'undefined') {
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
window.location = 'logout';
});

Return to:

Send suggestions and report system problems to the System administrator.