summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDave Cohen2008-09-19 20:44:48 (GMT)
committer Dave Cohen2008-09-19 20:44:48 (GMT)
commitc93a3625411bc76f2ce9e37f03f268d09dfc835d (patch)
tree74210e4dc022ea39f98b8ce1c58dcefa2863354b
parent81c50f06a51e7f2ced4f2a40dfe1a965ad098f60 (diff)
Initial support for Facebook Connect javascript. Very limited support - all API likely to change!
-rw-r--r--fb_connect.info3
-rw-r--r--fb_connect.module53
-rw-r--r--fb_connect_receiver.html7
3 files changed, 63 insertions, 0 deletions
diff --git a/fb_connect.info b/fb_connect.info
new file mode 100644
index 0000000..ea2fc1d
--- /dev/null
+++ b/fb_connect.info
@@ -0,0 +1,3 @@
+name = Facebook Connect
+description = Use fbConnect, and Facebook Javascript, on fbConnect aware themes.
+package = Facebook
diff --git a/fb_connect.module b/fb_connect.module
new file mode 100644
index 0000000..90dc433
--- /dev/null
+++ b/fb_connect.module
@@ -0,0 +1,53 @@
+<?php
+/**
+ * @file
+ * Support for Facebook Connect features
+ *
+ * Note that Facebook connect will work properly only with themes that are
+ * Facebook Connect aware.
+ */
+
+/**
+ * Allows other modules to specify which Facebook Connect features are
+ * required. This will affect how the FB_RequireFeatures javascript method is
+ * called.
+ */
+function fb_connect_require_feature($feature = NULL) {
+ static $features;
+ if (!$features)
+ $features = array();
+ if ($feature)
+ $features[] = $feature;
+ return $features;
+}
+
+/**
+ * Include facebook javascript in the footer of the current page.
+ */
+function fb_connect_footer($is_front) {
+ // Do nothing on FBML pages
+ if (function_exists('fb_canvas_is_fbml') && fb_canvas_is_fbml())
+ return;
+
+ global $fb_app; // Ok to use global here?
+ global $base_path;
+ $features = fb_connect_require_feature();
+ if (count($features) && $fb_app) {
+ // drupal_add_js cannot add external javascript, so we use hook_footer instead.
+ $output = '<script src="http://static.ak.connect.facebook.com/js/api_lib/v0.4/FeatureLoader.js.php" type="text/javascript"></script>';
+ $output .= "\n";
+ $feature_list = '["' . implode('","', $features) . '"]';
+ $receiver = $base_path . drupal_get_path('module', 'fb_connect') . "/fb_connect_receiver.html";
+ $output .= "
+<script type=\"text/javascript\">
+ $(document).ready(function() {
+ FB_RequireFeatures({$feature_list}, function () {
+ FB.Facebook.init(\"{$fb_app->apikey}\", \"{$receiver}\");
+ });
+ });
+</script>\n";
+ return $output;
+ }
+}
+
+?> \ No newline at end of file
diff --git a/fb_connect_receiver.html b/fb_connect_receiver.html
new file mode 100644
index 0000000..4fa56ba
--- /dev/null
+++ b/fb_connect_receiver.html
@@ -0,0 +1,7 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml" >
+<body>
+ <!-- http://wiki.developers.facebook.com/index.php/Cross_Domain_Communication_Channel -->
+ <script src="http://static.ak.connect.facebook.com/js/api_lib/v0.4/XdCommReceiver.debug.js" type="text/javascript"></script>
+</body>
+</html> \ No newline at end of file