Online Book Reader

Home Category

Facebook Cookbook - Jay Goldman [81]

By Root 764 0
and fb:wallpost tags if you wanted to format content to look like Wall posts, but since they don’t provide any mechanism to create new posts, they are much less useful. You can find more information about them on the Platform Wiki if you’re curious.

Discussion


The xid parameter needs to be unique across all of Facebook, so put on your imagining cap and make up something that no one else will have come up with (note that you’re limited to alphanumeric characters (Aa–Zz, 0–9), hyphens (-) and underscores (_)). You’ll see why it needs to be unique once you have the Wall on your page and you can see the URLs it uses for internal pages, which all point back to the same set of PHP pages for every Wall, passing in your xid to identify which Wall it should load content for.

You can control the maximum number of Posts you want visible by passing in a numposts parameter:

Two optional parameters control permission for the current user: canpost and candelete. The former defaults to true and the latter to false (for obvious security reasons). Facebook will automatically adjust the text about the number of visible posts, as seen in Figure 6-38. The default behavior for posting is to include the “Write Something” link (see the earlier screenshot in Figure 6-37), but you can switch to an inline form by setting showform to true (the page will refresh after posts to show the new ones; see Figure 6-39).

Figure 6-38. The fb:comments Wall with one post

Figure 6-39. The fb:comments Wall with showform set to true

Note that you’ll (obviously) need canpost set to true to use the form.

You might want to receive a Notification every time someone posts a comment so that you can jump in and check out what they’ve written. Pass in your uid as a send_notification_uid parameter. It unfortunately accepts only one uid, so set it to someone who will either keep up with the Wall herself or do a good job delegating.

The last two options give you control over the URLs used by the board. Both default to the current page, but you can choose to load a configuration from a different URL by specifying a callbackurl, or to have people pop out of the Wall onto a different page by specifying a returnurl. The documentation for fb:comments warns that every page load within the Wall will reload the configuration, so you should consider using the callbackurl to point Facebook to a page that is served from a potentially lower-cost or higher-bandwidth/reliability server, just in case hundreds of thousands of users storm down your door to talk about their cat’s penchant for ignoring them, demanding food, and sleeping a lot.

Finally, you can specify your own title for your board by throwing an fb:title tag into the fb:comments:

numposts="6"

canpost="true"

candelete="false"

send_notification_uid="12345"

showform="true"

callbackurl="http://superrobustserver.com/comments_config.php"

returnurl="http://apps.facebook.com/awesomegofish">

Talk about AGF!

Adding Profile Boxes and Info Sections


Problem


How can I give my users the opportunity to add a Profile Box if they don’t have one, or to add my app’s info to the Info tab of their Profile?

Solution


Use the fb:add-section-button to give users the ability to add either Profile Boxes or Info sections:

Discussion


This will render Facebook’s Add to Profile and Add to Info buttons, shown in Figure 6-40.

Figure 6-40. Add to Profile and Add to Info buttons

The Add to Profile button will appear only if you have previously called Profile.setFBML() for this user and he doesn’t already have your box on his Profile (on either the Wall or Boxes tab). Likewise, the Add to Info button will appear only if you have previously called Profile.setInfo() and the user doesn’t already have your Info section on his Info tab. See Getting and Setting Profile FBML for

Return Main Page Previous Page Next Page

®Online Book Reader