I have read the README multiple times. I am trying to get my Facebook application to generate a profile box. I just want the profile box to display a specific node from my site.
However, I don't know how to get users to be able to add the application. When they click on Go to Application, it simply takes them to the canvas page without asking them for authorization. Then there is no option to add a profile box for the application.
I have created an action to write to the profile box, and set it to fire when a user logs in to my site (I couldn't use any of the node triggers, as they were unavailable). I don't know if this is the right way to get data into the profile box, in any case. Any help you can give would be appreciated.
Comments
Comment #1
NigelC commentedAdd a button to your template for adding to profile:
http://wiki.developers.facebook.com/index.php/Fb:add-section-button
Comment #2
Dave Cohen commentedOnce upon a time users would "add" an application and automatically get a profile box. But that was the old way. Now, applications must get permission to do things like write a profile box. Facebook gives more control to users now.
Facebook provides pages where users can grant this sort of permission to each app. Also, applications can give users a chance to grant these permissions, using links and buttons authored in FBML. That means you can create a canvas page which gives the user a link to click on to add a profile box.
Drupal for Facebook, in fb_user.module, provides links for all extended permissions. If you have canvas pages enabled, try visiting app.facebook.com/YOUR_APP/user (the my account page). Then click the edit tab and the app sub-tab. There you should see links for various permissions and buttons for profile boxes. Why links in some cases and buttons in others? Ask Facebook. The idea behind this page, BTW, is that your app can implement hook_form_alter to show only the extended permissions which are actually relevent to your app.
Profile boxes are also weird in that you have to provide some content for the boxes before they can be added. In the Facebook App settings form you can provide a default profile box content.
See the link NigelC provided and also http://wiki.developers.facebook.com/index.php/Extended_permissions
Comment #3
EvanDonovan commentedIf I go to http://apps.facebook.com/urbanministry_test/user, it says "The page you have requested does not exist."
I'll look into the other links you've provided.
Comment #4
EvanDonovan commentedI have looked at the other links that you provided, and I'm still confused. It looks like I need to execute the profile_setFBML function before the Fb:add-section-button will show up, but I don't know how to go about doing that.
Comment #5
Dave Cohen commentedRegarding the profile_setFBML, the action you created to write to the profile box would normally do this. However in your case your app is not requiring users to authorize the app, so I don't think the action will actually fire. Because the DFF modules will not know which users are users of the app.
The /user path is not found because you have things set up so that, as far as Drupal is concerned, the user is anonymous even when logged into facebook. That's OK. But I think you'll need the user to authorize the app before they can add the profile box.
You can create a custom page to accomplish this. Try making a Drupal page, using the PHP input format, with a body something like this:
When you visit this page, facebook should prompt you to authorize the app. Then click the button, then check your profile boxes.
note: I haven't tested it, could be buggy.
Comment #6
EvanDonovan commentedThanks for the code. I got the profile box to show up now. However, my action is apparently not firing because I'm not seeing any content in the profile box - not even the test content added by the profile_setFBML function. It's like it doesn't save the content or something.
Comment #7
EvanDonovan commentedI can get the action to fire now, when I set the action to be on when a new page is added, instead of on user logging in. However, I get an error message in response: "Failed to set profile FBML: user id parameter or session key required 100. (logged into facebook as )".
From looking at a printout of my variables, it appears that the $fbu variable is not being set. Do you have any idea why that would be?
Comment #8
Dave Cohen commentedtake a look here for some examples: http://wiki.developers.facebook.com/index.php/Talk:Profile.setFBML
You may just need the fb:wide or fb:narrow wrapper. Its hard to tell when these problems are facebook bugs you must work around, or an error in the way you've called it.
Comment #9
EvanDonovan commentedIt appears that my uid when I am on Facebook is not the same as my uid on Drupal. Thus, the authmap lookup fails and $fbu is not set.
Comment #10
EvanDonovan commentedIn fact, my uid on Facebook is a completely new user, with the information about the user populated from the currently logged-in Facebook account. At first, this made me confused since the user was called Evan Donovan, so I thought it was my regular Drupal user. But now I see that it is always named after the Facebook user who is currently logged in.
How can I get the Facebook app to link up with the currently logged in Drupal user?
Comment #11
Dave Cohen commentedThe app settings on drupal are stored in a node. The node type is Facebook Application. Find that node and edit it. There is a fieldset for user settings. In there you can control whether Drupal for Facebook automatically creates Drupal users for each Facebook user, and whether it "maps" the accounts. Make sure those settings are on.
Comment #12
EvanDonovan commentedAgain, thanks for your help. I have my settings as follows:
* Require Login: Allow logged-in users
* Create local account: If user has logged in
* Map accounts: Map accounts when both local uid and Facebook id are known
* New user role: Authenticated user
Still, the uid on Facebook is not the same as the uid on my site urbanministry.org. Is this because it's a XSS issue otherwise?
Since I needed to update multiple profiles at once, I'm trying the cron job method of updating a Facebook ref tag. However, it doesn't seem like the profiles are actually being updated. Is there any documentation on how that works?
Comment #13
Dave Cohen commentedThe uid in drupal will not be the same as the facebook id. In code, I call the facebook ids "fbu".
try this query on your database:
SELECT * FROM authmap;what do you see?
Comment #14
EvanDonovan commentedThe first of those should map to uid 12, however, since that's the user who was logged on to UrbanMinistry.org (my Drupal site) at the time.
It seems like going to user/login on my Facebook app creates an error. When I log on, it tries to load the user page (i.e., user/evandonovan) but then it gives the "There are still a few kinks that Facebook and the makers of Urban Ministry Test 2 are trying to work out" error message.
Comment #15
Dave Cohen commentedIt doesn't work that way. When you visit apps.facebook.com/whatever, it makes no difference whether you're logged into whatever.com. It created a new local user.
Use your browser's view source feature. As the app developer, Facebook often includes helpful hints on pages with error messages. Probably, it's Drupal not letting you visit user/login, because you're already logged in.
Comment #16
EvanDonovan commentedOh, okay. That's what I was wondering. So then, how do I get my actions to trigger when I am logged in to my site? It says that the user id parameter is required, but I can't get one, since the users on my site don't have Facebook users associated with them in the authmap table.
Comment #17
NigelC commentedI guess you would need to somehow link the two users - the user who logged in via facebook and the user who logged in via drupal directly. Not exactly sure how this works as I only create users from facebook.
For the FBML profile box, why not do it as a cron job rather than as logged in user?
I guess it depends on what you are trying to do, but for example my profile box is generated based on user editable info in the user profile (and based on cron data). Therefore I updated it when the user updates their profile (so the user is logged on), and based on a cron (it runs through x number of users per cron).
Anyway, regardless I think your problem is that the facebook user is different to the drupal login user. Dave will have to comment on if you can link these (I seem to recall something like that).
Comment #18
Dave Cohen commentedThe facebook user id and the drupal id are mapped via Drupal's authmap table, but if and only if you select the appropriate checkbox on the Facebook Application node.
Comment #19
Dave Cohen commentedfacebook did away with profile boxes.