First off,
The module works wonderfully and the API along with its documentation is fantastic.

Right now, if I need to initate any facebook action, I output a link using

fboauth_action_display('my_custom_action');

When a user clicks on it, a popup with request for relevant permission turns up etc.

I was wondering if it was at all possible to initiate the popup (i.e. the facebook request) when a user browses to a given path say 'something/my_custom_action_page' which is implemented as a MENU_CALLBACK in my custom module.

AFAI-understand, the callback provided for a custom action takes the app_id and the access_token as params. I was thinking of making the menu item's callback the same as the action callback. I am thinking correctly. Is there a API function provided by fboauth that I have somehow missed that would let me do this?

Thanks.

Comments

v-a-1’s picture

I meant "Am I thinking correctly?". Sorry.

quicksketch’s picture

The README.txt describes what you need I think:

Or an alternative if you don't want to use the fboauth_action_display() function
to print out the link, you can simply grab the link properties from the
fboauth_action_link_properties() function and output the link manually:

$link = fboauth_action_link_properties('connect');
print l(t('Connect'), $link['href'], array('query' => $link['query']));

You can call fboauth_action_link_properties() in your menu callback, then use drupal_goto($link['href']) to immediately initiate the action, taking the user to Facebook's website for confirmation.

v-a-1’s picture

Thanks! That put me in the right direction.

However,
drupal_goto($link['href'])
doesn't work directly, because the query params are not attached to the link yet.

This is what works: (I call it from my menu callback).

  $fb_link_array = fboauth_action_link_properties('my_custom_action'); //get link array from fboauth module for making fb request.
  $full_fb_url = url($fb_link_array['href'], array('absolute' => TRUE, 'query' => $fb_link_array['query'])); //build the fboauth url
  drupal_goto($full_fb_url); 

Thanks again.

quicksketch’s picture

Right, right of course. I think you can actually pass those arguments directly to drupal_goto() also, but it's probably more clear the way you've written it.

quicksketch’s picture

Status: Active » Fixed

Status: Fixed » Closed (fixed)

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