I have a functioning D7 "Post to Facebook" module
I have a Drupal 7 Facebook publish module and implementation working and working well, based on "imoreno's" work on the drupal site. Great job by the way on this module. Thanks imoreno. It's called fb_nc_publish. Please see this string for the module: http://drupal.org/node/1142518
My question is how do we simply add the Page/Group/User option to this module. Ive been playing with some solutions but can't seem to get the code to publish to a facebook page or group. I've followed Dave Cohen's advice with D6 and it works fine, but with this new fb_nc_publish module. I've yet to be able to get publish.stream to function properly. Any help...where should I add the publish.stream (target_id)?? Please help, thanks.
Lets go with your fb_nc_publish.module as a starting point. I have it working and functioning properly. How do I redirect the publish to a page wall?
Here's the .module code, any ideas?
<?php
/**
* Implements hook_form_{$form_id}_alter().
*
*/
function fb_nc_publish_form_node_type_form_alter(&$form, &$form_state) {
$type = $form['#node_type'];
$form['fb_nc_publish'] = array(
'#type' => 'fieldset',
'#title' => t('Publish to Facebook'),
'#collapsible' => TRUE,
'#collapsed' => TRUE,
'#group' => 'additional_settings',
'#attached' => array(
'js' => array(
'vertical-tabs' => drupal_get_path('module', 'fb_nc_publish') . '/fb_nc_publish.js',
),
),
);
$form['fb_nc_publish']['fb_nc_publish_node_publish'] = array(
'#type' => 'checkbox',
'#title' => t('Allow nodes of this type to be published in Facebook Stream.'),
'#default_value' => variable_get('fb_nc_publish_node_publish_' . $type->type, 0),
'#return_value' => 1,
);
$form['fb_nc_publish']['fb_nc_publish_comments_publish'] = array(
'#type' => 'checkbox',
'#title' => t('Allow comments on this node type to be published in Facebook Stream.'),
'#default_value' => variable_get('fb_nc_publish_comments_publish_' . $type->type, 0),
'#return_value' => 1,
);
}
/**
* Implements hook_form_alter().
*/
function fb_nc_publish_form_alter(&$form, &$form_state, $form_id) {
if (isset($form['#node'])) {
$token = fb_vars();
if ($token['fbu']) { //show only if logged in with facebook
$type = $form['#node']->type;
$entity = $form['#entity_type'];
if ( ($entity == 'node' && variable_get('fb_nc_publish_node_publish_' . $type, 0)) ||
($entity == 'comment' && variable_get('fb_nc_publish_comments_publish_' . $type, 0)) ) {
$form['fb_nc_publish'] = array(
'#type' => 'checkbox',
'#title' => t('Publish to my facebook stream'),
'#return_value' => 1,
'#weight' => 0,
'#default_value' => 1,
);
}
}
}
}
/**
* Implements hook_node_insert().
*/
function fb_nc_publish_node_insert($node) {
if (isset($node->fb_nc_publish) && variable_get('fb_nc_publish_node_publish_' . $node->type, 0) && $node->fb_nc_publish) {
$uri = node_uri($node);
_fb_nc_publish_publish($node->title, $node->body[LANGUAGE_NONE][0]['value'], $uri['path']);
}
}
/**
* Implements hook_node_update().
*/
function fb_nc_publish_node_update($node) {
fb_stream_publish_dialog(array(
'target_id' => '227776495096',
'message' => $user_message,
'attachment' => $attachment,
'action_links' => $actions,
));
fb_nc_publish_node_insert($node);
}
/**
* Implements hook_comment_insert();
*/
function fb_nc_publish_comment_insert($comment) {
$type = str_replace('comment_node_', '', $comment->node_type);
if (isset($comment->fb_nc_publish) && variable_get('fb_nc_publish_comments_publish_' . $type, 0) && $comment->fb_nc_publish) {
$uri = comment_uri($comment);
$node = node_load($comment->nid);
$subject = $node->title;
if (!empty($comment->subject)) {
$subject .= ': ' . $comment->subject;
}
_fb_nc_publish_publish($subject, $comment->comment_body[LANGUAGE_NONE][0]['value'], $uri['path']);
}
}
/**
* Publish to FB
*/
function _fb_nc_publish_publish($subject, $body, $path) {
try {
if (!empty($subject) || !empty($body)) {
$token = fb_vars();
$fb = $token['fb'];
$access_token = fb_get_token($fb, $token['fbu']);
$link = url($path, array('absolute' => TRUE));
$body = strip_tags($body);
$params = array(
'access_token' => $access_token,
'description' => (empty($body)? $subject : $body),
'link' => $link, //permalink to the node/comment
'name' => (!empty($subject)? $subject : $link),
);
$result = $fb->api('/me/feed/', 'post', $params);
}
}
catch (Exception $ex) {
drupal_set_message(t('Unable to post to your Facebook wall'), 'error');
watchdog_exception('fb_nc_publish', $ex);
}
}
/**
* Implements hook_TYPE_alter().
*/
function fb_nc_publish_fb_required_perms_alter(&$perms) {
$perms[] = 'publish_stream';
}- Forums:

How awesome you are
Very
It might help to look at
It might help to look at this: http://drupal.org/node/1454736
Its for D6, and not based on the module you mention. If anyone is interested in upgrading to D7 that would be awesome.