Building Yahoo! Social Applications with Flash

Use the expressiveness and cross-browser goodness that Flash and Flex provide to build a fun and powerful application using the Yahoo! Social APIs on your own website, AIR application, or from within an Open Application.

All code and samples are provided free of charge under a BSD license.

Yahoo Social Applications in Flash

This SDK is released alpha and is experimental due to the insecure nature of OAuth 1.0 in client-side applications.

Getting Started

Requirements

To use the ActionScript 3 Social SDK, you'll need:

  • A web server that allows POST requests
  • A means of grabbing POST variables and creating a query string
  • Basic knowledge of ActionScript 3 with Flash or Flex

If you are using YAP and the ActionScript 3 SDK, authorization will effectively be taken care of, so you won't need to learn the details of using OAuth. However, if you wish to handle authorization yourself, you may find the PHP SDK helpful on the server-side.

Creating A New Application

To get started, you'll need to set up a new app and get a consumer key and secret in order to access the Social APIs.

If you are targeting your app to run within YAP, create a new Open Application and use the developer tool to create, preview and deploy your application. For a Flash application you will use this tool along with YML (Yahoo! Markup Language) to embed your application.

Get started by following these steps:

Once you've set up an new application, you'll get the necessary keys you can use for development and testing.

If you are implementing authorization yourself, may also find it helpful to read about OAuth Authorization.

Downloading The Package

The component is distributed with full source code, a Flex 3 SWC, documentation and a Yahoo! styled CSS skin. To use in Flex Builder or Flash CS3, drop the source into your project's 'src' directory. You can also use the single SWC file in Flex Builder by dropping it into your project's 'libs' directory, or point to it in the project build path.

Note: The API uses the open-source JSON utility in as3corelib. For the latest and greatest version of as3corelib, check out the project page.

This SDK is released alpha and is experimental due to the insecure nature of OAuth 1.0 in client-side applications.

Get the SDK from our Github Project Page.

Using the YOS API and Components

This API provides an easy entry point for a Flash or Flex developer, enabling full use of the Yahoo! Social APIs in ActionScript 3. Through this API you are able to create a session, query for friends of a user and get their profile information, all through simple and familiar ActionScript.

Be sure to check out the class reference documentation to get familiar with the API.

Creating a User Session

In order to create a session, you are required to pass an OAuth consumer key / secret and an access token / secret in order to begin a session.

By passing these values along to the YahooSession object, you then can fetch the sessioned user, the object that represents the user viewing the application.

See the section on Authentication for more on this topic.

Alternatively, if your app runs within YAP, you can instantiate a session directly using the user and access token parameters in the flashvars.

Getting User Information

Once you have a YahooUser created, you can then begin making social data requests such as loading profile information and connections.

Getting Friends Data

One of the more popular uses is to display a list of friends, and that's easily accomplished by calling the getConnections method on the user's connections property.

Using YQL

YQL provides a single, straight-forward endpoint for developers to access structured data across Yahoo! and beyond. As part of this SDK, an familiar ActionScript interface is provided to make using YQL that much easier.

If you have a sessioned user, you can query for their social data.

Using the CSS Files in Flex

The skin is provided for you to drop into your Flex applications, giving a slick, standard interface out-of-the-box. All you need to do is add a Style tag to your Flex application, pointing to the yap_ui.css file.

Example CSS Skin

Good Things To Know

Building a Flash Application in YAP

If you are targeting your application on the Yahoo! Application Platform, there a few things to keep in mind as you begin to build your app using Flash. Most importantly, you must use YML to embed your SWF into the app. By default, yml:swf will pass a set of flashvars specifying some environment variables, such as the current app view, viewer and owner GUIDs.

However, when displaying your Flash application in YAP, not all of the required variables are passed through using yml:swf. Therefore, you'll need a way of passing these from YAP manually. Using PHP, a quick way of passing them through is by turning the POST array into a query string. To help get you started, the following is an example using PHP 5. However, please note, because this effectively prints your variables to the page, it is not a very secure method. This is only meant to get you started.

YAP will also handle OAuth for you by sending the access token and secret in the POST request to your app. You can use these directly instead of making a separate request to our OAuth servers.

Authentication & Security in Flash

Building an application with security in mind is always a good development practice.

When using OAuth, you are provided a consumer key and secret, and can make a request for an access token and secret. You should avoid printing these tokens anywhere on your page (don't use with flashvars) or hard-coding them into the SWF. Doing so could expose the keys to the public.

However, due to the nature of client applications, this typically means that the consumer secret must be distributed with the application, which inherently compromises them. As such, it is not recommended to allow the application to fetch user data via any authenticated API. You may find the PHP SDK very useful for making server-side OAuth requests.

Terms of Use

Use of the Yahoo! Social APIs is governed by the Yahoo! APIs Terms of Use.

Ready to get started?

Recent Blog Articles

Yahoo! Groups Discussions

Create/Edit flash file on the fly

Tue, 15 May 2012

Re: TabBar actual width

Tue, 27 Mar 2012

Re: TabBar actual width

Fri, 09 Mar 2012

TabBar actual width

Fri, 09 Mar 2012

start and end time comparison

Wed, 07 Mar 2012

More