This feature will post a node's teaser and link back to the node onto a facebook wall.
This is a site-wide setting, meaning that the target wall is configured by a site administrator (as opposed to a user who may or may not be currently connected to facebook). The idea is to echo on a facebook page content of a certain node type. For example, post all your events to your facebook fan page.
Please review patch and leave feedback here.
To configure, enable fb_stream.module and check the appropriate boxes on the user permission form. Then...
* Get an access token
Go to Admin >> Site Building >> Facebook Applications >> Stream
Posts. Now, you will see a link near the bottom of the form, "post
via the Your App applicaton." Click this link, and click through
the dialogs which prompt for the needed permissions.
Press "Save Configuration".
* Configure the Content Types
Do the following for any types which may need links posted to Facebook.
Start at Admin >> Content Management >> Content Types.
Click "edit" next to the Story content type.
Open the "Facbook Posts" fieldset. Check the "Enable Post to
Facebook" checkbox. Also select the post author and wall. The
options shown here depend on the user who generated the access
token, and which pages that user administers. Note the author of
the facebook post is a facebook id, not associated with the Drupal
uid of the editor.
Press "Save Content Type".
* Post to Facebook When Editing Content
When editing a Story, the Drupal user will see a "Post to Facebook" fieldset.
Check "Post to Facebook" in order to post, when the node is saved.
Optionally, provide a message, which will precede the post text on facebook.
Optionally, override the wall where the post appears.
Save the node. Then (in another browser) visit the facebook wall to
confirm the post succeeded.
* Troubleshooting
The access token may be invalidated, even if offline_access is
granted. If invalid, none of the posting will succeed. and Drupal
administrators will see errors. (Note that content will still be
saved, the errors will not prevent that.)
To remedy an invalid token, you must generate a new token. AND ALSO
re-save each content type that has this feature enabled.
Unfortunately, you must visit each content type form and re-save the
settings.
For any other problems, enable the fb_devel.module. And add this
snippet to your settings.php:
$conf['fb_verbose'] = TRUE; // Make fb_devel.module more verbose.
fb_devel.module will log any problems that it notices, which can
often speed up troubleshooting.
| Comment | File | Size | Author |
|---|---|---|---|
| #2 | fb_stream_site_wide_post.diff | 17.38 KB | Dave Cohen |
| fb_stream_site_wide_post.diff | 12.8 KB | Dave Cohen |
Comments
Comment #1
jroos commentedI tried it, but I'm getting a HTTP Error 500 (Internal Server Error) when I try to access the "Stream Posts" page.
The message in the log is:
require_once(sites/all/modules/fb/fb_stream.admin.inc) [<a href='function.require-once'>function.require-once</a>]: failed to open stream: No such file or directory in includes/menu.inc on line 347.I think that more than just the patch is required because I don't see a fb_stream.admin.inc anywhere.
If I'm just being clueless and missing something, please forgive me.
Comment #2
Dave Cohen commentedMy fault. Here's a patch with that file.
(I have a hate-hate relationship with git. I never seem to do anything right the first time around.)
Comment #3
jroos commentedI did get it working with a little trouble on the Facebook end.
Now I have feature requests. :)
It would be great to set the default state of the checkbox and the message box (per content type of course).
Comment #4
Dave Cohen commentedThe reason the checkbox defaults to unchecked is because a node might get edited over and over. I think its better not to spam a facebook wall with every edit. A future version of this might get more sophisticated, and know whether a node has already been posted, but that's another level of complexity.
The message I suppose could have a default without any problems. I guess my thinking was that piece would be specific to the node being posted.
Both reasonable suggestions and food for thought. If anyone wants to contribute a patch, please let me know.
Comment #5
jroos commentedI am having a problem now. When a non-admin user tries to post it doesn't work and returns the error "Unable to post content to facebook".
The role does have the "post to site-wide facebook stream" permission. However, when I add "override facebook stream details" it works.
Is that the way it's supposed to be?
Comment #6
Dave Cohen commentedThat's not how it is supposed to be. Is there more error info in the drupal log?
Comment #7
jroos commentedThat would be helpful wouldn't it. I hope there's nothing here that I should have redacted. Here you go:
Post to Facebook stream failed.: fb_graph failed querying 150678401659593/feed. OAuthException: (#200) This API call requires a valid app_id.
exception 'Exception' with message 'fb_graph failed querying 150678401659593/feed. OAuthException: (#200) This API call requires a valid app_id.' in /home1/stcloudl/public_html/main/sites/all/modules/fb/fb.module:515
Stack trace:
#0 /home1/stcloudl/public_html/main/sites/all/modules/fb/fb_stream.module(71): fb_graph()
#1 /home1/stcloudl/public_html/main/modules/node/node.module(678): fb_stream_nodeapi('150678401659593...', Array, 'POST')
#2 /home1/stcloudl/public_html/main/modules/node/node.module(937): node_invoke_nodeapi()
#3 /home1/stcloudl/public_html/main/modules/node/node.pages.inc(455): node_save()
#4 /home1/stcloudl/public_html/main/includes/form.inc(781): node_form_submit(Object(stdClass), 'insert', NULL, NULL)
#5 /home1/stcloudl/public_html/main/includes/form.inc(421): form_execute_handlers(Object(stdClass), 'insert')
#6 /home1/stcloudl/public_html/main/includes/form.inc(120): drupal_process_form(Object(stdClass))
#7 /home1/stcloudl/public_html/main/sites/all/modules/context_admin/plugins/context_admin/node_create_menu.inc(99): drupal_get_form()
#8 /home1/stcloudl/public_html/main/includes/module.inc(461): context_admin_node_create_menu_render_page(Array, Array)
#9 /home1/stcloudl/public_html/main/sites/all/modules/context_admin/plugins/task_handlers/menu_context.inc(444): module_invoke()
#10 /home1/stcloudl/public_html/main/sites/all/modules/ctools/includes/context-task-handler.inc(46): context_admin_menu_context_render('submit', Array, Array)
#11 /home1/stcloudl/public_html/main/sites/all/modules/ctools/page_manager/plugins/tasks/page.inc(335): ctools_context_handler_render('sermon_node_for...', Array, Array)
#12 /home1/stcloudl/public_html/main/includes/menu.inc(349): page_manager_page_execute('sermon_node_for...', Array)
#13 /home1/stcloudl/public_html/main/index.php(17): menu_execute_active_handler()
#14 {main}
Comment #8
j_byrd commentedThis is exactly what I've been looking for, but when I click on "post via..." in "Stream Posts", I get the following:
I tried generating a new token, but have the same problem.
Any help would be appreciated.
Thanks
Comment #9
j_byrd commentedSolved this by going directly to Graph API Explorer, clicking on my application and copying and pasting the token into "Stream Posts".
Works beautifully!
Comment #10
j_byrd commentedWhen you say "This feature will post a node's teaser and link back to the node onto a facebook wall", does that mean it will display the teaser from the node body or the teaser as defined in "Display fields"?
Comment #11
j_byrd commentedIn trying to create content or bring up an edit page I got the following error:
PHP Fatal error: Call to undefined function drupal_set_messages() in */httpdocs/sites/all/modules/fb/fb_stream.module on line 192and the page wouldn't load.
I changed "drupal_set_messages()" to "drupal_set_message()", then got this message
Also had to get a new access token; will that be necessary each time I want to use Facebook?
Comment #12
j_byrd commentedCurrently, it looks like access tokens are only good for 2 hours: https://developers.facebook.com/blog/post/2011/05/13/how-to--handle-expi..., but...
"On May 2, 2012, the offline_access permission will be removed. If you are building a new application you shouldn't use this permission. Instead please check the Deprecation of Offline Access Permission document which explains how to start using access tokens that are valid for up to 60 days."
https://developers.facebook.com/docs/authentication/
Comment #13
cimo75 commentedHi
how to post to a facebook fan page instead of to the profile ?
Simone
Comment #14
j_byrd commentedFollow the instructions above using the patch in #2
Comment #15
cimo75 commentedOk, just to help out anybody else looking for this: as far as i can tell you have to be an administrator of the page, then you have to go here: https://developers.facebook.com/tools/explorer while logged in as a profile, choose you application in the up-right tab, then you need to be sure that you check the " manage_pages" permission.
After that you ll be able to chose one of the pages you are an administrator of..
S.
Comment #16
cimo75 commentedIt seems like you don t have to choose your application in the Application tab but leave as it is: Graph API Explorer.
Now I d need to deal with the expiration terms. I ve read through the documentation but I really haven t understood how to get those 60 days valid tokens. Any help?
tx
Simone
Comment #17
Dave Cohen commentedSo, I'm trying to decouple the "app has to be hosted on drupal" aspect of modules/fb. That's why this feature allows you to paste an access token into that form. The tricky part is when you generate that token, you need the right extended permissions. As cimo75 points out, manage_pages helps when posting to a page. Another critical (IMHO) one is offline_access, which will prevent the token from expiring, solving j_byrd's problem. Sadly, facebook has deprecated offline_access so it may not always be available.
Note that if you are hosting the app on your Drupal, you should see a link to help you generate the access token, with the right permissions, right on the page provided by this patch.
Comment #18
Dave Cohen commentedI'm setting to fixed, not because the feature is perfect (as the recent comments indicate it is not), but because I have pushed the patch into the .dev build, to be included in the next 3.x release.
For enhancements and specific bug reports, please open new issues. I'll read comments here, but only until drupal.org closes this issue.
Comment #19
sylvain_a commentedHello,
Thank you for the patch.
Any direction I could look if I keep getting this error,
after following every comment above?
I got the token from https://developers.facebook.com/tools/explorer with manage_pages and publish_stream
"Post to Facebook stream failed.: fb_graph failed querying 5*********/feed.
OAuthException: (#100) link URL is not properly formatted."
Thank you,
SA
Comment #20
j_byrd commentedMy tokens seemed to expire whether I had offline_access enabled or not. I just tried disabling the "Extended Permissions" module (which I had enabled in another attempt to add content to my Facebook fan page) and things seem to be working much better. Haven't waited two hours, yet, but the link "post via the Your App applicaton" at Admin >> Site Building >> Facebook Applications >> Stream Posts worked for the first time.
Access expires after 2 hours. Is there a way to double check that offline_access is truly enabled? I check the enabling box, but haven't seen any confirmation about what is enabled.
Comment #21
cimo75 commentedj_byrd offline_access is deprecated
http://developers.facebook.com/live_status
we need a new way to get the extended permission. Follow on
http://drupal.org/node/1557186
Simone
Comment #22
Dave Cohen commentedI bet some of the confusion comes from administering drupal and logging into facebook in the same browser. Try administering drupal in one browser, not logged into facebook. Do all your facebook testing and facebook.com/developers work in another browser. Cut and paste from browser to browser when necessary (i.e. app ids, secrets, access tokens)
Comment #23
j_byrd commentedYou're absolutely right!
Comment #26
luksakAccording to #1536610: post to facebook BEHALF of the page which i am admin of . and #1862648: How to stream post to Facebook Page as Facebook App? this feature has not been ported to 7.x? Why is this marked as fixed?
Comment #27
warmth commentedI'm on latest Drupal 7 using Fb dev and I see the option to stream, I'm just configuring it right now.
Comment #28
Dave Cohen commentedIf there's a problem with 7.x branch, please submit a new issue.
Comment #30
cellulose commentedHello,
I have problem setting my Drupal instance for post on my facebook page. Perhaps, with this patch it would be ok. But I wonder if is it made for a drupal 7? Another obvious thing is about the app registration it asks me the rights to use my profile informations but no question about the rights to write on my page. Moreover, on the admin/module page for the fb_stream.module there is a link that points on canvas facebook page:
(fb_stream.module) APIs for posting to Facebook Streams (a.k.a. News Feed or Wall)
Requiert : Facebook API (activé)
So my question, what is the canvas path?
Thank you for your help!