개발자 뉴스
Updating the New Facebook Connect JavaScript SDK

We're excited to release the first update to our open source Facebook Connect JavaScript SDK, currently in alpha. The SDK has two key pieces of new functionality: basic support for XFBML and an advanced data layer for optimizing FQL queries.

We launched the SDK last month, and in that short amount of time we've seen interest and adoption from a wide variety of websites, including CBS' The Insider blog and Where I've Been, which updated their live implementations with the new SDK.

Adding XFBML Support

The first release of the SDK concentrated on core features like login and publishing. Now we're adding basic support for XFBML, the Facebook markup language used on Facebook Connect sites. In the SDK, XFBML parsing is entirely in your control, so you can easily render Facebook data when and where you like.

For example, you can render a user's name as it appears on Facebook by formatting your XFBML code like this:

 <fb:name uid="2901279">
 <script type="text/javascript">
   FB.init({api_key: API_KEY});
   FB.XFBML.parse();
 </script>

At this time, because we are still in alpha, we've implemented these four tags: fb:name, fb:profile-pic, fb:login-button, and fb:share. We are working on adding the rest in the coming weeks.

Optimizing FQL Queries

We've implemented an advanced data layer for optimizing FQL queries. It provides an easy-to-use JavaScript interface on top of fql.multiquery, which enables you to make multiple dependent queries in one request. Additionally, the data layer optimizes queries automatically, and in the future will make use of local browser cache to avoid requests altogether.

For example, you can return a user's name and profile picture by formatting your FQL query code like this:

var query = FB.Data.query(
    'SELECT name, pic FROM user '
   +'WHERE uid = {0}',
     FB._session.uid);
query.wait(function(rows) {
    document.getElementById('name').innerHTML = 
     'Your name is: ' + rows[0].name
});

Getting Started

You can download the SDK from GitHub and read the FAQ and documentation. We look forward to your continued feedback in the Developer Forum.

Wei, a software engineer on the Platform team, enjoys working to make the Web more open and social.