| Package | com.dasflash.soundcloud.as3api |
| Class | public class SoundcloudClient |
| Inheritance | SoundcloudClient flash.events.EventDispatcher |
Create an instance of this class and call its authentication methods to
connect your app with the Soundcloud REST API. Once you're authenticated you
can call every resource through the sendRequest method.
You can also call public resources without going through the authentication process.
See also
| Property | Defined By | ||
|---|---|---|---|
| responseFormat : String
Sets the format of the server response (XML or JSON). | SoundcloudClient | ||
| useOAuth1_0 : Boolean
Set to true for legacy OAuth 1.0 authentication (not recommended). | SoundcloudClient | ||
| useSandBox : Boolean
Determines whether the SoundCloud sandbox system is used (recommended for testing)
or the live service. | SoundcloudClient | ||
| Property | Defined By | ||
|---|---|---|---|
| accessToken : OAuthToken | SoundcloudClient | ||
| callbackURL : String | SoundcloudClient | ||
| consumer : OAuthConsumer | SoundcloudClient | ||
| consumerKey : String | SoundcloudClient | ||
| consumerSecret : String | SoundcloudClient | ||
| requestToken : OAuthToken | SoundcloudClient | ||
| Method | Defined By | ||
|---|---|---|---|
SoundcloudClient(consumerKey:String, consumerSecret:String, accessToken:OAuthToken = null, useSandbox:Boolean = true, responseFormat:String = xml)
Creates a Soundcloud API client. | SoundcloudClient | ||
authorizeUser(targetWindow:String = _blank):void
Opens authorization page to grant data access for your app. | SoundcloudClient | ||
getAccessToken(verificationCode:String = null, externalRequestToken:OAuthToken = null):SoundcloudDelegate
Retrieves the access token. | SoundcloudClient | ||
getRequestToken(callbackURL:String = null):SoundcloudDelegate
Retrieves a request token. | SoundcloudClient | ||
sendRequest(resource:String, method:String, data:Object = null):SoundcloudDelegate
Make a request to the API. | SoundcloudClient | ||
| Method | Defined By | ||
|---|---|---|---|
createDelegate(resource:String, method:String, data:Object = null, responseFormat:String, dataFormat:String, requestToken:OAuthToken = null):SoundcloudDelegate
Sends the actual API call. | SoundcloudClient | ||
| Event | Summary | Defined By | ||
|---|---|---|---|---|
| Dispatched when the client receives an access token after getAccessToken has been called. | SoundcloudClient | |||
| Dispatched when the request of getAccessToken has failed. | SoundcloudClient | |||
| Dispatched when the client receives a request token after getRequestToken has been called. | SoundcloudClient | |||
| Dispatched when the request of getRequestToken has failed. | SoundcloudClient | |||
| Constant | Defined By | ||
|---|---|---|---|
| accessTokenResource : String = oauth/access_token | SoundcloudClient | ||
| requestTokenResource : String = oauth/request_token | SoundcloudClient | ||
| accessToken | property |
protected var accessToken:OAuthToken| callbackURL | property |
protected var callbackURL:String| consumer | property |
protected var consumer:OAuthConsumer| consumerKey | property |
protected var consumerKey:String| consumerSecret | property |
protected var consumerSecret:String| requestToken | property |
protected var requestToken:OAuthToken| responseFormat | property |
responseFormat:StringSets the format of the server response (XML or JSON). The value must be SoundcloudResponseFormat.JSON, .XML or an empty String (default) which will also return XML.
public function get responseFormat():String public function set responseFormat(value:String):void| useOAuth1_0 | property |
useOAuth1_0:Boolean
Set to true for legacy OAuth 1.0 authentication (not recommended).
public function get useOAuth1_0():Boolean public function set useOAuth1_0(value:Boolean):void| useSandBox | property |
useSandBox:BooleanDetermines whether the SoundCloud sandbox system is used (recommended for testing) or the live service.
public function get useSandBox():Boolean public function set useSandBox(value:Boolean):void| SoundcloudClient | () | Constructor |
public function SoundcloudClient(consumerKey:String, consumerSecret:String, accessToken:OAuthToken = null, useSandbox:Boolean = true, responseFormat:String = xml)Creates a Soundcloud API client.
If no consumerKey and consumerSecret are passed
to this function you can only access public resources (e.g. "tracks") and cannot retrieve a request token.
Else if you have consumerKey and consumerSecret but no accessToken,
you can only call public resources and getRequestToken.
consumerKey:String — The consumer key you receive when registering your app with Soundcloud (optional).
| |
consumerSecret:String — The consumer secret you receive when registering your app with Soundcloud (optional).
| |
accessToken:OAuthToken (default = null) — A previously retrieved access token for the current user (optional).
| |
useSandbox:Boolean (default = true) — Switch between the Soundcloud live system (false) and the developer.
sandbox system (true, default)
| |
responseFormat:String (default = xml) — "json" or "xml" (default).
|
| authorizeUser | () | method |
public function authorizeUser(targetWindow:String = _blank):voidOpens authorization page to grant data access for your app.
Parameters
targetWindow:String (default = _blank) — (optional)
Target window name, defaults to "_blank". Use "_self" to open the
authentication page in the current window
|
| createDelegate | () | method |
protected function createDelegate(resource:String, method:String, data:Object = null, responseFormat:String, dataFormat:String, requestToken:OAuthToken = null):SoundcloudDelegateSends the actual API call.
Parameters
resource:String — The resource locator, e.g. "user/myUserId/tracks"
| |
method:String — GET, POST, PUT or DELETE. Note that FlashPlayer
only supports GET and POST as of this writing.
AIR supports all four methods.
| |
data:Object (default = null) — (optional) The data to be sent. This can be a generic object
containing request parameters as key/value pairs or a XML object
| |
responseFormat:String — (optional) Tells Soundcloud whether to render response as JSON or XML.
Value must be SoundcloudResponseFormat.JSON, .XML or an empty String
(default) which will also return XML
| |
dataFormat:String — (optional) "binary", "text" (default) or "variables"
| |
requestToken:OAuthToken (default = null) — (optional) Overwrites the access token. Used to pass the
request token when requesting an access token.
|
SoundcloudDelegate — A SoundcloudDelegate instance you can attach a listener to
for the SoundcloudEvent and SoundcloudFault events
|
| getAccessToken | () | method |
public function getAccessToken(verificationCode:String = null, externalRequestToken:OAuthToken = null):SoundcloudDelegateRetrieves the access token.
This token will be used for all subsequent API calls. You should store it and reuse it the next time the current user opens your app.
Parameters
verificationCode:String (default = null) — The code that is displayed on the confirmation page
after user authorization. This parameter is optional because it
won't be generated when you use legacy OAuth 1.0 authentication
| |
externalRequestToken:OAuthToken (default = null) — A previously saved request token. You need to use this
parameter when you want to call getAccessToken from the callbackURL page
|
SoundcloudDelegate — A SoundcloudDelegate instance you can attach a listener to for
the SoundcloudEvent and SoundcloudFault events
|
| getRequestToken | () | method |
public function getRequestToken(callbackURL:String = null):SoundcloudDelegateRetrieves a request token.
This token must be traded for an access token by calling getAccessToken() after user authentication
Parameters
callbackURL:String (default = null) — (optional)
the user will be redirected to this page after authentication.
this url will be extended with parameters that you can use
on the page:
oauth_token: the request token the user authorized or denied
oauth_verifier: the verification code (only for OAuth 1.0a)
|
SoundcloudDelegate — a SoundcloudDelegate instance you can attach a listener to for
the SoundcloudEvent and SoundcloudFault events
|
| sendRequest | () | method |
public function sendRequest(resource:String, method:String, data:Object = null):SoundcloudDelegateMake a request to the API.
Parameters
resource:String — The resource locator, e.g. "user/myUserId/tracks"
| |
method:String — GET, POST, PUT or DELETE. Note that FlashPlayer only supports GET
and POST as of this writing. AIR supports all four methods.
| |
data:Object (default = null) — (optional) A generic object containing the request parameters
|
SoundcloudDelegate — A SoundcloudDelegate instance you can attach a listener to for
the SoundcloudEvent and SoundcloudFault events
|
| accessToken | Event |
com.dasflash.soundcloud.as3api.events.SoundcloudAuthEventcom.dasflash.soundcloud.as3api.events.SoundcloudAuthEvent.ACCESS_TOKEN
Dispatched when the client receives an access token after getAccessToken has
been called.
Wait for this event before calling any non-public resources. If you're building an AIR application you can also use this event to store the access token in the local file system.
| accessTokenFault | Event |
com.dasflash.soundcloud.as3api.events.SoundcloudFaultEventcom.dasflash.soundcloud.as3api.events.SoundcloudFaultEvent.ACCESS_TOKEN_FAULT
Dispatched when the request of getAccessToken has failed.
The most likely reason is that the verification code was wrong. Other reasons could be network
problems, a bad request token or an invalid user. You can check this events message and
errorCode properties for details.
| requestToken | Event |
com.dasflash.soundcloud.as3api.events.SoundcloudAuthEventcom.dasflash.soundcloud.as3api.events.SoundcloudAuthEvent.REQUEST_TOKEN
Dispatched when the client receives a request token after getRequestToken has
been called.
Wait for this event before continuing with the next step in the authentication process,
authorizeUser.
| requestTokenFault | Event |
com.dasflash.soundcloud.as3api.events.SoundcloudFaultEventcom.dasflash.soundcloud.as3api.events.SoundcloudFaultEvent.REQUEST_TOKEN_FAULT
Dispatched when the request of getRequestToken has failed.
This event most likely occurs when there are network problems. You can check this events
message and errorCode properties for details.
| accessTokenResource | Constant |
protected const accessTokenResource:String = oauth/access_token| requestTokenResource | Constant |
protected const requestTokenResource:String = oauth/request_token
var scClient:SoundcloudClient = new SoundcloudClient();
var delegate:SoundcloudDelegate = scClient.sendRequest("tracks");
delegate.addEventListener(SoundcloudEvent.REQUEST_COMPLETE, requestCompleteHandler);
protected function requestCompleteHandler(event:SoundcloudEvent):void
{
trace(event.data);
}