Closed (fixed)
Project:
Drupal for Facebook
Version:
6.x-3.0-rc13
Component:
Code
Priority:
Normal
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
31 May 2011 at 15:40 UTC
Updated:
15 Jun 2011 at 19:31 UTC
Hi,
I'm trying to get page id with code that Dave provided, but get this strange error every time:
Fatal error: Call to a member function getSignedRequest() on a non-object in /home/likeid/public_html/sites/all/modules/rules/rules/modules/php.rules.inc(107) : eval()'d code on line 2
The code is next:
extract(fb_vars());
$sr = $fb->getSignedRequest();
echo $sr->page->id;
I put this code in php snippet. What am I missing here?
Comments
Comment #1
Dave Cohen commentedThe
$fbis not always initialized. so put aif ($fb) { ... }after theextract().Usually there will be a
$fb, on all canvas pages, and on regular pages when there is a "primary" app. If not, there will only be an $fb when some code has explicitly initialized it.Comment #2
krembo commentedSo you mean if someone visit my application at page tab, the $fb will be initialized?
Comment #3
Dave Cohen commentedYes, on a page tab, the $fb should be initialized.
Comment #4
krembo commentedThanks, Dave.
I tried that. Now there are no errors, but it still doesn't work... How can I initialize $fb in code?
Comment #5
krembo commentedMaybe you can help me with that in other way. When user in facebook entering page tab with my application,
I want to redirect him on one page if he is admin(sort of admin panel ),
and on the other if he is usual user(get the page id and redirect to "page/HERE-GOES-PAGE-ID").
And second thing get the page id, and put it in some field in content type.
Comment #6
krembo commentedUpdate:
Just the second question still not solved.
Comment #7
krembo commentedBoth solved, but I used external function to make this happen...
Would like to know why it didn't work with getSignedRequest()
Comment #8
Dave Cohen commentedSo fixed?
If you have a useful solution, please share it.
Comment #9
krembo commentedIt's actually work around with code that i have found on the net.
This is the snippet I used for redirect the admin/non admin.
And the second one is to add this string in code:
And then just put the value into the hidden field in webform, that placed on 'node/2'.
After that just one Rule and field populated with desired value.
I know this isn't the best solution in drupal. Just couldn't make it work with DFF. Still would like to know if it possible.