Time for action – posting via the SDK

There are two ways to post data to Facebook using the SDK. The first involves the Facebook.api() method that we've been using all along, so let's start with that.

Normally, we pass three parameters to this method:

  • A URL stub
  • A callback function
  • An AS3 object containing the arguments to pass to Facebook (in this case, just message)

When publishing, we need to pass a fourth variable:

  • The HTTP request method to use

From our work with the HTTP Requestor, you already know that this needs to be POST. So, modify the publish() method of SDKRequestor.as, like so:

public function publish(a_publishObject:PublishObject):void
{
  var urlStub:String = "/me/feed";
  Facebook.api(urlStub, publishComplete,
{ message:a_publishObject.message ...

Get Facebook Graph API Development with Flash now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.