I just happen to have spent the last few days doing just that.
Text Formatted Code
function CUSTOM_getFooterCode(){
global $_CONF, $_SCRIPTS;
if(preg_match('/\/story.php\?mode=edit/i', $_SERVER['REQUEST_URI']) && isset($_CONF['facebook_consumer_key'])){
$_SCRIPTS->setJavaScriptLibrary('jquery');
return ' <div id="fb-root"></div>
<script type="text/javascript">
jQuery(document).ready(function(){
var theForm =
\'<fieldset>\'+
\'<legend>Publish directly to a Facebook wall</legend>\'+
\'<div style="padding:2px 0;"><label for="fb_to">Facebook page, id or username of target wall:</label><input type="text" name="fb_to" value="" /><span style="font-size: 62%;"> Optional</span></div>\'+
\'<div style="padding:2px 0;"><label for="fb_from">Facebook id or username of poster:</label><input type="text" name="fb_from" value=""/><span style="font-size: 62%;"> Optional</span></div>\'+
\'<div style="padding:2px 0;"><input type="button" value="Publish to Facebook" name="publish_to_facebook" /><span style="font-size: 62%;"> Will open separate window.</span></div>\'+
\'<span style="font-size: 62%; color: #ff0000;">You must be admin of target wall.</span>\'+
\'</fieldset>\';
jQuery(\'#se_publish>fieldset:last\').append(theForm);
jQuery(\'input[name="publish_to_facebook"]\').live(\'click\', function(e){
e.preventDefault();
publishToStream();
});
});
window.fbAsyncInit = function(){
FB.init({
appId: '.$_CONF['facebook_consumer_key'].',
status: true,
cookie: true,
xfbml: true,
oauth : true
});
FB.login(function(response) {}, {scope: \'publish_stream, offline_access, manage_pages\'});
};
(function(){
var e = document.createElement("script");
e.async = true;
e.src = document.location.protocol +
"//connect.facebook.net/en_US/all.js";
document.getElementById("fb-root").appendChild(e);
}());
function publishToStream(){
var args = {
to: (jQuery(\'input[name="fb_to"]\').val() != "")?jQuery(\'input[name="fb_to"]\').val():"me",
from: jQuery(\'input[name="fb_from"]\').val(),
name: jQuery(\'input[name="title"]\').val(),
link: "'.$_CONF['site_url'].'/article.php?story="+jQuery(\'input[name="sid"]\').val(),
caption: " ",
picture: "'.$_CONF['site_url'].'/images/speck.gif",
description: stripHtml(jQuery(\'#introtext\').text()),
actions: [{
name: "Read More...",
link: "'.$_CONF['site_url'].'/article.php?story="+jQuery(\'input[name="sid"]\').val()
}]
}
if(args.from !== ""){
FB.api("/me/accounts", function(response) {
for (var i=0, l=response.data.length; i<l; i++) {
if(response.data[i].id == args.from || response.data[i].name == args.from){
args.from = response.data[i].id;
args.access_token = response.data[i].access_token;
sendMsg(args);
break;
}
}
});
}else{
sendMsg(args);
}
}
function sendMsg(args){
FB.api("/"+args.to+"/feed", "post", args, function(response){
if (!response || response.error) {
alert(\'An error occurred\');
} else {
alert(\'Post ID: \' + response.id);
}
});
}
function stripHtml(html) {
var tmp = document.createElement("DIV");
tmp.innerHTML = html;
return tmp.textContent||tmp.innerText;
}
</script>'."\n";
}else if(preg_match('/\/calendar\/index.php\?mode=edit/i', $_SERVER['REQUEST_URI']) && isset($_CONF['facebook_consumer_key'])){
$_SCRIPTS->setJavaScriptLibrary('jquery');
return ' <div id="fb-root"></div>
<script type="text/javascript">
jQuery(document).ready(function(){
var theForm =
\'<fieldset>\'+
\'<legend>Publish a new Facebook event</legend>\'+
\'<div style="padding:2px 0;"><label for="fb_to">Facebook page, id to publish event to:</label><input type="text" name="fb_to" value="" /><span style="font-size: 62%;"> Optional</span></div>\'+
\'<div style="padding:2px 0;"><label for="fb_from">Facebook id or username of poster:</label><input type="text" name="fb_from" value=""/><span style="font-size: 62%;"> Optional</span></div>\'+
\'<div style="padding:2px 0;"><input type="button" value="Publish to Facebook" name="publish_to_facebook" /><span style="font-size: 62%;"> Will open separate window.</span></div>\'+
\'<span style="font-size: 62%; color: #ff0000;">You must be admin of page or user.</span>\'+
\'</fieldset>\';
jQuery(\'form[name="events"]\').append(theForm);
jQuery(\'input[name="publish_to_facebook"]\').live(\'click\', function(e){
e.preventDefault();
createEvent();
});
});
window.fbAsyncInit = function(){
FB.init({
appId: '.$_CONF['facebook_consumer_key'].',
status: true,
cookie: true,
xfbml: true,
oauth : true
});
FB.login(function(response) {}, {scope: \'create_event, offline_access, manage_pages\'});
};
(function(){
var e = document.createElement("script");
e.async = true;
e.src = document.location.protocol +
"//connect.facebook.net/en_US/all.js";
document.getElementById("fb-root").appendChild(e);
}());
function createEvent(){
var to = (jQuery(\'input[name="fb_to"]\').val() != "")?jQuery(\'input[name="fb_to"]\').val():"me";
var args = {
owner: jQuery(\'input[name="fb_from"]\').val(),
name: jQuery(\'input[name="title"]\').val(),
start_time: jQuery(\'select[name="start_month"]\').val()+"/"+jQuery(\'select[name="start_day"]\').val()+"/"+jQuery(\'select[name="start_year"]\').val()+" "+jQuery(\'select[name="start_hour"]\').val()+"\:"+jQuery(\'select[name="start_minute"]\').val()+jQuery(\'select[name="start_ampm"]\').val(),
end_time: jQuery(\'select[name="end_month"]\').val()+"/"+jQuery(\'select[name="end_day"]\').val()+"/"+jQuery(\'select[name="end_year"]\').val()+" "+jQuery(\'select[name="end_hour"]\').val()+"\:"+jQuery(\'select[name="end_minute"]\').val()+jQuery(\'select[name="end_ampm"]\').val(),
location: stripHtml(jQuery(\'textarea[name="location"]\').text()),
description: stripHtml(jQuery(\'textarea[name="description"]\').text()+"\n '.$_CONF['site_url'].'/calendar/event.php?eid="+jQuery(\'input[name="eid"]\').val()),
venue: {street: jQuery(\'input[name="address1"]\').val()+" "+jQuery(\'input[name="address2"]\').val(),
city: jQuery(\'input[name="city"]\').val(),
state: jQuery(\'input[name="state"]\').val(),
zip: jQuery(\'input[name="zipcode"]\').val(),
country: "", latitude: "", longitude: ""}
};
if(isNumber(to))args.page_id = to;
FB.api("/"+to+"/events", "post", args, function(response){
if (!response || response.error) {
alert(\'An error occurred\');
} else {
alert(\'Event ID: \' + response.id);
}
});
}
function stripHtml(html) {
var tmp = document.createElement("DIV");
tmp.innerHTML = html;
return tmp.textContent||tmp.innerText;
}
function isNumber(n) {
return !isNaN(parseFloat(n)) && isFinite(n);
}
</script>'."\n";
} else {
return '';
}
}
If you haven't already created an app for your site, head over to https://developers.facebook.com/apps and create a new app.
Finally enter your Facebook "App ID" into geeklog configuration -> Users and Submissions -> Facebook OAuth Application ID
Now a button should appear in the story editor under the "Publish Options" tab.
I plan on dropping this into a plugin here in the next few days if you can wait.