feed stories, tokens, and fb_feed_show_dialog_alter

nighthawk117 - October 15, 2009 - 19:49
Project:Drupal for Facebook
Version:6.x-2.x-dev
Component:Code
Category:support request
Priority:normal
Assigned:Unassigned
Status:closed
Description

I'm having the following problem, I'd like to use the "title" token in my feed story but I get the following error:

"Application response error

Supplied template data does not cover the following tokens [title] needed for template '{*actor*} just added {*title*}.' You can see this because you are one of the developers of the app."

So, I've setup a module with the following hook:

function fb_feed_story_fb_feed_show_dialog_alter(&$params){
$params['tokens'] = array('[title]' => 'test');
//kpr($params);die;
}

But that doesn't quite seem to do the trick... I'm assuming I don't know the proper way to set the $params['tokens'] field. Has anyone successfully done this before? If so, can you point me in the right direction of how to set this field to replace the value of the token "{*title*}" with "test"?

#1

nighthawk117 - October 15, 2009 - 23:17

Also tried array('title' => 'test');

#2

nighthawk117 - October 16, 2009 - 17:47

Ok, I've done a deeper dive on this and it appears that if I use the following hook:

function fb_feed_story_fb_feed_show_dialog_alter(&$params){
  $params['tokens'] = array('title' => 'test');
}

AND I modify fb_feed.module line 601 to read

$args[] = json_encode(array_merge($d['options'][$key], $d['tokens']));

then everything works! So, it seems this is a bug in fb_feed.module...

#3

Dave Cohen - October 17, 2009 - 11:51

$params['tokens'] helps you to use Drupal tokens when showing feed dialogs. And the drupal token api uses a strange data structure not at all like what you're creating.

Instead, use the alter hook to add your values to $params['options']['template_data']. This will be passed to the showfeeddialog function the way you expect. And you can alter other parameters to the function, see http://wiki.developers.facebook.com/index.php/Facebook.showFeedDialog.

And undo the change you've made to line 601. That will break the handling of the other parameters.

#4

nighthawk117 - October 19, 2009 - 17:51

Thanks Dave, that works. I guess this is obvious to people more familiar with Drupal!

#5

Dave Cohen - October 19, 2009 - 18:57
Status:active» fixed

Not obvious to anyone, really. I tried to make the parameters reflect the documentation of the facebook methods. But there's little rhyme or reason to what they do over there at facebook.

#6

System Message - November 2, 2009 - 19:00
Status:fixed» closed

Automatically closed -- issue fixed for 2 weeks with no activity.

 
 

Drupal is a registered trademark of Dries Buytaert.