|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectorg.urbanstew.soundcloudapi.SoundCloudAPI
public class SoundCloudAPI
| Nested Class Summary | |
|---|---|
static class |
SoundCloudAPI.OAuthVersion
|
static class |
SoundCloudAPI.SoundCloudSystem
|
static class |
SoundCloudAPI.State
|
| Field Summary | |
|---|---|
static SoundCloudOptions |
USE_PRODUCTION
|
static SoundCloudOptions |
USE_SANDBOX
|
| Constructor Summary | |
|---|---|
SoundCloudAPI(SoundCloudAPI soundCloudAPI)
Constructor from another SoundCloudAPI. |
|
SoundCloudAPI(java.lang.String consumerKey,
java.lang.String consumerSecret)
Constructor for the case when neither the request or access token have been obtained. |
|
SoundCloudAPI(java.lang.String consumerKey,
java.lang.String consumerSecret,
SoundCloudOptions options)
Constructor for the case when neither the request or access token have been obtained, with specified options. |
|
SoundCloudAPI(java.lang.String consumerKey,
java.lang.String consumerSecret,
java.lang.String token,
java.lang.String tokenSecret)
Constructor for the case when the access token has been obtained. |
|
SoundCloudAPI(java.lang.String consumerKey,
java.lang.String consumerSecret,
java.lang.String token,
java.lang.String tokenSecret,
SoundCloudOptions options)
Constructor for the case when the access token has been obtained, with specified options. |
|
| Method Summary | |
|---|---|
boolean |
authorizeUsingUrl(java.lang.String url,
java.lang.String response,
AuthorizationURLOpener URLOpener)
Completes the OAuth 1.0a authorization steps with SoundCloud, assuming the consumer application can use a local port to receive the verification code. |
void |
cancelAuthorizeUsingUrl()
If a call to authorizeUsingUrl is currently executing, it will be canceled and return shortly after cancelAuthorizeUsingUrl is called. |
org.apache.http.HttpResponse |
delete(java.lang.String resource)
Performs a DELETE request on a specified resource. |
org.apache.http.HttpResponse |
delete(java.lang.String resource,
java.util.List<org.apache.http.NameValuePair> params)
Performs a DELETE request on a specified resource, with parameters. |
org.apache.http.client.methods.HttpUriRequest |
deleteRequest(java.lang.String resource,
java.util.List<org.apache.http.NameValuePair> params)
Prepares a DELETE request on a specified resource, with parameters. |
org.apache.http.HttpResponse |
get(java.lang.String resource)
Performs a GET request on a specified resource. |
org.apache.http.HttpResponse |
get(java.lang.String resource,
java.util.List<org.apache.http.NameValuePair> params)
Performs a GET request on a specified resource, with parameters. |
java.lang.String |
getRedirectedStreamUrl(java.lang.String resource)
Returns a URL you can use to access a stream resource without any further need for signing. |
org.apache.http.client.methods.HttpUriRequest |
getRequest(java.lang.String resource,
java.util.List<org.apache.http.NameValuePair> params)
Prepares a GET request on a specified resource, with parameters. |
SoundCloudAPI.State |
getState()
Returns the current state of the API wrapper. |
org.apache.http.HttpResponse |
getStream(java.lang.String resource)
|
org.apache.http.HttpResponse |
getStreamRedirect(java.lang.String url)
Executes a GET request for the given URL, without following any redirects. |
java.lang.String |
getToken()
Returns the Request or Access Token. |
java.lang.String |
getTokenSecret()
Returns the Request or Access Token Secret. |
void |
obtainAccessToken(java.lang.String verificationCode)
Swaps the authorized request token for an access token. |
java.lang.String |
obtainRequestToken()
Obtains the request token from Sound Cloud |
java.lang.String |
obtainRequestToken(java.lang.String callbackURL)
Obtains the request token from Sound Cloud, with a specified callback URL. |
java.lang.String |
parseRedirectResponse(org.apache.http.HttpResponse response)
Utility function that returns the value of the Location header in a redirect response. |
org.apache.http.HttpResponse |
post(java.lang.String resource)
Performs a POST request on a specified resource. |
org.apache.http.HttpResponse |
post(java.lang.String resource,
org.apache.http.HttpEntity entity)
Performs a POST request on a specified resource, with an entity. |
org.apache.http.HttpResponse |
post(java.lang.String resource,
java.util.List<org.apache.http.NameValuePair> params)
Performs a POST request on a specified resource, with parameters. |
org.apache.http.client.methods.HttpUriRequest |
postRequest(java.lang.String resource,
org.apache.http.HttpEntity entity)
Prepares a POST request on a specified resource, with an entity. |
org.apache.http.client.methods.HttpUriRequest |
postRequest(java.lang.String resource,
java.util.List<org.apache.http.NameValuePair> params)
Prepares a POST request on a specified resource, with parameters. |
org.apache.http.HttpResponse |
put(java.lang.String resource)
Performs a PUT request on a specified resource. |
org.apache.http.HttpResponse |
put(java.lang.String resource,
org.apache.http.HttpEntity entity)
Performs a PUT request on a specified resource, with an entity. |
org.apache.http.HttpResponse |
put(java.lang.String resource,
java.util.List<org.apache.http.NameValuePair> params)
Performs a PUT request on a specified resource, with parameters. |
org.apache.http.client.methods.HttpUriRequest |
putRequest(java.lang.String resource,
org.apache.http.HttpEntity entity)
Prepares a PUT request on a specified resource, with an entity. |
org.apache.http.client.methods.HttpUriRequest |
putRequest(java.lang.String resource,
java.util.List<org.apache.http.NameValuePair> params)
Prepares a PUT request on a specified resource, with parameters. |
java.lang.String |
signStreamUrl(java.lang.String url)
Signs the provided URL. |
void |
unauthorize()
|
org.apache.http.HttpResponse |
upload(org.apache.http.entity.mime.content.ContentBody fileBody,
java.util.List<org.apache.http.NameValuePair> params)
Uploads an arbitrary body by performing a POST request on the "tracks" resource. |
org.apache.http.HttpResponse |
upload(java.io.File file,
java.util.List<org.apache.http.NameValuePair> params)
Uploads a file by performing a POST request on the "tracks" resource. |
| Methods inherited from class java.lang.Object |
|---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static final SoundCloudOptions USE_SANDBOX
public static final SoundCloudOptions USE_PRODUCTION
| Constructor Detail |
|---|
public SoundCloudAPI(java.lang.String consumerKey,
java.lang.String consumerSecret)
public SoundCloudAPI(java.lang.String consumerKey,
java.lang.String consumerSecret,
SoundCloudOptions options)
public SoundCloudAPI(java.lang.String consumerKey,
java.lang.String consumerSecret,
java.lang.String token,
java.lang.String tokenSecret)
public SoundCloudAPI(java.lang.String consumerKey,
java.lang.String consumerSecret,
java.lang.String token,
java.lang.String tokenSecret,
SoundCloudOptions options)
public SoundCloudAPI(SoundCloudAPI soundCloudAPI)
| Method Detail |
|---|
public void unauthorize()
public java.lang.String obtainRequestToken()
throws oauth.signpost.exception.OAuthMessageSignerException,
oauth.signpost.exception.OAuthNotAuthorizedException,
oauth.signpost.exception.OAuthExpectationFailedException,
oauth.signpost.exception.OAuthCommunicationException
oauth.signpost.exception.OAuthCommunicationException
oauth.signpost.exception.OAuthExpectationFailedException
oauth.signpost.exception.OAuthNotAuthorizedException
oauth.signpost.exception.OAuthMessageSignerException
public java.lang.String obtainRequestToken(java.lang.String callbackURL)
throws oauth.signpost.exception.OAuthMessageSignerException,
oauth.signpost.exception.OAuthNotAuthorizedException,
oauth.signpost.exception.OAuthExpectationFailedException,
oauth.signpost.exception.OAuthCommunicationException
oauth.signpost.exception.OAuthCommunicationException
oauth.signpost.exception.OAuthExpectationFailedException
oauth.signpost.exception.OAuthNotAuthorizedException
oauth.signpost.exception.OAuthMessageSignerException
public boolean authorizeUsingUrl(java.lang.String url,
java.lang.String response,
AuthorizationURLOpener URLOpener)
throws oauth.signpost.exception.OAuthMessageSignerException,
oauth.signpost.exception.OAuthNotAuthorizedException,
oauth.signpost.exception.OAuthExpectationFailedException,
oauth.signpost.exception.OAuthCommunicationException,
java.io.IOException
The function acts as a minimal HTTP server and will listen on the port specified in the
url (or the default HTTP port, if no port is specified in the url). It will provide the
specified response when it receives a request for the path specified in the url, and
assuming the request includes the verification code, terminate successfully.
To all other requests it will respond with a Not Found error, and continue listening.
The following example assumes the consumer application is running on the client's computer / device. Hence, it uses a local URL ("http://localhost:8088/") to receive the verification code callback. The function will listen on specified port 8088 to receive the callback.
soundcloudapi.authorizeUsingUrl
(
"http://localhost:8088/",
"Thank you for authorizing",
new AuthorizationURLOpener()
{
public void openAuthorizationURL(String authorizationURL)
{
System.out.println("Please visit " + authorizationURL);
}
}
);
url - - a callback URL via which the user can provide the verification code.response - - a response given back to the user when they allow access and get redirected to the callback URL.URLOpener - - an AuthorizationURLOpener which can open the authorization URL to the user when needed.
cancelAuthorizeUsingUrl.
oauth.signpost.exception.OAuthCommunicationException
oauth.signpost.exception.OAuthExpectationFailedException
oauth.signpost.exception.OAuthNotAuthorizedException
oauth.signpost.exception.OAuthMessageSignerException
java.io.IOExceptioncancelAuthorizeUsingUrl()public void cancelAuthorizeUsingUrl()
authorizeUsingUrl(String, String, AuthorizationURLOpener)
public void obtainAccessToken(java.lang.String verificationCode)
throws oauth.signpost.exception.OAuthMessageSignerException,
oauth.signpost.exception.OAuthNotAuthorizedException,
oauth.signpost.exception.OAuthExpectationFailedException,
oauth.signpost.exception.OAuthCommunicationException
oauth.signpost.exception.OAuthCommunicationException
oauth.signpost.exception.OAuthExpectationFailedException
oauth.signpost.exception.OAuthNotAuthorizedException
oauth.signpost.exception.OAuthMessageSignerException
public org.apache.http.HttpResponse get(java.lang.String resource)
throws oauth.signpost.exception.OAuthMessageSignerException,
oauth.signpost.exception.OAuthExpectationFailedException,
org.apache.http.client.ClientProtocolException,
java.io.IOException,
oauth.signpost.exception.OAuthCommunicationException
oauth.signpost.exception.OAuthExpectationFailedException
oauth.signpost.exception.OAuthMessageSignerException
java.io.IOException
org.apache.http.client.ClientProtocolException
oauth.signpost.exception.OAuthCommunicationException
public org.apache.http.HttpResponse get(java.lang.String resource,
java.util.List<org.apache.http.NameValuePair> params)
throws oauth.signpost.exception.OAuthMessageSignerException,
oauth.signpost.exception.OAuthExpectationFailedException,
org.apache.http.client.ClientProtocolException,
java.io.IOException,
oauth.signpost.exception.OAuthCommunicationException
oauth.signpost.exception.OAuthExpectationFailedException
oauth.signpost.exception.OAuthMessageSignerException
java.io.IOException
org.apache.http.client.ClientProtocolException
oauth.signpost.exception.OAuthCommunicationException
public org.apache.http.client.methods.HttpUriRequest getRequest(java.lang.String resource,
java.util.List<org.apache.http.NameValuePair> params)
throws oauth.signpost.exception.OAuthMessageSignerException,
oauth.signpost.exception.OAuthExpectationFailedException,
oauth.signpost.exception.OAuthCommunicationException
oauth.signpost.exception.OAuthExpectationFailedException
oauth.signpost.exception.OAuthMessageSignerException
oauth.signpost.exception.OAuthCommunicationException
public org.apache.http.HttpResponse put(java.lang.String resource)
throws oauth.signpost.exception.OAuthMessageSignerException,
oauth.signpost.exception.OAuthExpectationFailedException,
org.apache.http.client.ClientProtocolException,
java.io.IOException,
oauth.signpost.exception.OAuthCommunicationException
oauth.signpost.exception.OAuthExpectationFailedException
oauth.signpost.exception.OAuthMessageSignerException
java.io.IOException
org.apache.http.client.ClientProtocolException
oauth.signpost.exception.OAuthCommunicationException
public org.apache.http.HttpResponse put(java.lang.String resource,
java.util.List<org.apache.http.NameValuePair> params)
throws oauth.signpost.exception.OAuthMessageSignerException,
oauth.signpost.exception.OAuthExpectationFailedException,
org.apache.http.client.ClientProtocolException,
java.io.IOException,
oauth.signpost.exception.OAuthCommunicationException
oauth.signpost.exception.OAuthExpectationFailedException
oauth.signpost.exception.OAuthMessageSignerException
java.io.IOException
org.apache.http.client.ClientProtocolException
oauth.signpost.exception.OAuthCommunicationException
public org.apache.http.client.methods.HttpUriRequest putRequest(java.lang.String resource,
java.util.List<org.apache.http.NameValuePair> params)
throws oauth.signpost.exception.OAuthMessageSignerException,
oauth.signpost.exception.OAuthExpectationFailedException,
oauth.signpost.exception.OAuthCommunicationException
oauth.signpost.exception.OAuthExpectationFailedException
oauth.signpost.exception.OAuthMessageSignerException
oauth.signpost.exception.OAuthCommunicationException
public org.apache.http.HttpResponse put(java.lang.String resource,
org.apache.http.HttpEntity entity)
throws oauth.signpost.exception.OAuthMessageSignerException,
oauth.signpost.exception.OAuthExpectationFailedException,
org.apache.http.client.ClientProtocolException,
java.io.IOException,
oauth.signpost.exception.OAuthCommunicationException
oauth.signpost.exception.OAuthExpectationFailedException
oauth.signpost.exception.OAuthMessageSignerException
java.io.IOException
org.apache.http.client.ClientProtocolException
oauth.signpost.exception.OAuthCommunicationException
public org.apache.http.client.methods.HttpUriRequest putRequest(java.lang.String resource,
org.apache.http.HttpEntity entity)
throws oauth.signpost.exception.OAuthMessageSignerException,
oauth.signpost.exception.OAuthExpectationFailedException,
oauth.signpost.exception.OAuthCommunicationException,
java.io.UnsupportedEncodingException
oauth.signpost.exception.OAuthExpectationFailedException
oauth.signpost.exception.OAuthMessageSignerException
oauth.signpost.exception.OAuthCommunicationException
java.io.UnsupportedEncodingException
public org.apache.http.HttpResponse post(java.lang.String resource)
throws oauth.signpost.exception.OAuthMessageSignerException,
oauth.signpost.exception.OAuthExpectationFailedException,
org.apache.http.client.ClientProtocolException,
java.io.IOException,
oauth.signpost.exception.OAuthCommunicationException
oauth.signpost.exception.OAuthExpectationFailedException
oauth.signpost.exception.OAuthMessageSignerException
java.io.IOException
org.apache.http.client.ClientProtocolException
oauth.signpost.exception.OAuthCommunicationException
public org.apache.http.HttpResponse post(java.lang.String resource,
java.util.List<org.apache.http.NameValuePair> params)
throws oauth.signpost.exception.OAuthMessageSignerException,
oauth.signpost.exception.OAuthExpectationFailedException,
org.apache.http.client.ClientProtocolException,
java.io.IOException,
oauth.signpost.exception.OAuthCommunicationException
oauth.signpost.exception.OAuthExpectationFailedException
oauth.signpost.exception.OAuthMessageSignerException
java.io.IOException
org.apache.http.client.ClientProtocolException
oauth.signpost.exception.OAuthCommunicationException
public org.apache.http.client.methods.HttpUriRequest postRequest(java.lang.String resource,
java.util.List<org.apache.http.NameValuePair> params)
throws oauth.signpost.exception.OAuthMessageSignerException,
oauth.signpost.exception.OAuthExpectationFailedException,
oauth.signpost.exception.OAuthCommunicationException,
java.io.UnsupportedEncodingException
oauth.signpost.exception.OAuthExpectationFailedException
oauth.signpost.exception.OAuthMessageSignerException
oauth.signpost.exception.OAuthCommunicationException
java.io.UnsupportedEncodingException
public org.apache.http.HttpResponse post(java.lang.String resource,
org.apache.http.HttpEntity entity)
throws oauth.signpost.exception.OAuthMessageSignerException,
oauth.signpost.exception.OAuthExpectationFailedException,
org.apache.http.client.ClientProtocolException,
java.io.IOException,
oauth.signpost.exception.OAuthCommunicationException
oauth.signpost.exception.OAuthExpectationFailedException
oauth.signpost.exception.OAuthMessageSignerException
java.io.IOException
org.apache.http.client.ClientProtocolException
oauth.signpost.exception.OAuthCommunicationException
public org.apache.http.client.methods.HttpUriRequest postRequest(java.lang.String resource,
org.apache.http.HttpEntity entity)
throws oauth.signpost.exception.OAuthMessageSignerException,
oauth.signpost.exception.OAuthExpectationFailedException,
oauth.signpost.exception.OAuthCommunicationException,
java.io.UnsupportedEncodingException
oauth.signpost.exception.OAuthExpectationFailedException
oauth.signpost.exception.OAuthMessageSignerException
oauth.signpost.exception.OAuthCommunicationException
java.io.UnsupportedEncodingException
public org.apache.http.HttpResponse delete(java.lang.String resource)
throws oauth.signpost.exception.OAuthMessageSignerException,
oauth.signpost.exception.OAuthExpectationFailedException,
org.apache.http.client.ClientProtocolException,
java.io.IOException,
oauth.signpost.exception.OAuthCommunicationException
oauth.signpost.exception.OAuthExpectationFailedException
oauth.signpost.exception.OAuthMessageSignerException
java.io.IOException
org.apache.http.client.ClientProtocolException
oauth.signpost.exception.OAuthCommunicationException
public org.apache.http.HttpResponse delete(java.lang.String resource,
java.util.List<org.apache.http.NameValuePair> params)
throws oauth.signpost.exception.OAuthMessageSignerException,
oauth.signpost.exception.OAuthExpectationFailedException,
org.apache.http.client.ClientProtocolException,
java.io.IOException,
oauth.signpost.exception.OAuthCommunicationException
oauth.signpost.exception.OAuthExpectationFailedException
oauth.signpost.exception.OAuthMessageSignerException
java.io.IOException
org.apache.http.client.ClientProtocolException
oauth.signpost.exception.OAuthCommunicationException
public org.apache.http.client.methods.HttpUriRequest deleteRequest(java.lang.String resource,
java.util.List<org.apache.http.NameValuePair> params)
throws oauth.signpost.exception.OAuthMessageSignerException,
oauth.signpost.exception.OAuthExpectationFailedException,
oauth.signpost.exception.OAuthCommunicationException
oauth.signpost.exception.OAuthExpectationFailedException
oauth.signpost.exception.OAuthMessageSignerException
oauth.signpost.exception.OAuthCommunicationException
public org.apache.http.HttpResponse upload(java.io.File file,
java.util.List<org.apache.http.NameValuePair> params)
throws oauth.signpost.exception.OAuthMessageSignerException,
oauth.signpost.exception.OAuthExpectationFailedException,
org.apache.http.client.ClientProtocolException,
java.io.IOException,
oauth.signpost.exception.OAuthCommunicationException
oauth.signpost.exception.OAuthExpectationFailedException
oauth.signpost.exception.OAuthMessageSignerException
java.io.IOException
org.apache.http.client.ClientProtocolException
oauth.signpost.exception.OAuthCommunicationException
public org.apache.http.HttpResponse upload(org.apache.http.entity.mime.content.ContentBody fileBody,
java.util.List<org.apache.http.NameValuePair> params)
throws oauth.signpost.exception.OAuthMessageSignerException,
oauth.signpost.exception.OAuthExpectationFailedException,
org.apache.http.client.ClientProtocolException,
java.io.IOException,
oauth.signpost.exception.OAuthCommunicationException
oauth.signpost.exception.OAuthExpectationFailedException
oauth.signpost.exception.OAuthMessageSignerException
java.io.IOException
org.apache.http.client.ClientProtocolException
oauth.signpost.exception.OAuthCommunicationException
public java.lang.String signStreamUrl(java.lang.String url)
throws oauth.signpost.exception.OAuthMessageSignerException,
oauth.signpost.exception.OAuthExpectationFailedException,
oauth.signpost.exception.OAuthCommunicationException
oauth.signpost.exception.OAuthExpectationFailedException
oauth.signpost.exception.OAuthMessageSignerException
oauth.signpost.exception.OAuthCommunicationException
public org.apache.http.HttpResponse getStreamRedirect(java.lang.String url)
throws oauth.signpost.exception.OAuthMessageSignerException,
oauth.signpost.exception.OAuthExpectationFailedException,
oauth.signpost.exception.OAuthCommunicationException,
org.apache.http.client.ClientProtocolException,
java.io.IOException
oauth.signpost.exception.OAuthExpectationFailedException
oauth.signpost.exception.OAuthMessageSignerException
oauth.signpost.exception.OAuthCommunicationException
org.apache.http.client.ClientProtocolException
java.io.IOExceptionpublic java.lang.String parseRedirectResponse(org.apache.http.HttpResponse response)
public java.lang.String getRedirectedStreamUrl(java.lang.String resource)
throws oauth.signpost.exception.OAuthMessageSignerException,
oauth.signpost.exception.OAuthExpectationFailedException,
oauth.signpost.exception.OAuthCommunicationException,
org.apache.http.client.ClientProtocolException,
java.io.IOException
oauth.signpost.exception.OAuthExpectationFailedException
oauth.signpost.exception.OAuthMessageSignerException
oauth.signpost.exception.OAuthCommunicationException
org.apache.http.client.ClientProtocolException
java.io.IOException
public org.apache.http.HttpResponse getStream(java.lang.String resource)
throws oauth.signpost.exception.OAuthMessageSignerException,
oauth.signpost.exception.OAuthExpectationFailedException,
org.apache.http.client.ClientProtocolException,
java.io.IOException,
oauth.signpost.exception.OAuthCommunicationException
oauth.signpost.exception.OAuthMessageSignerException
oauth.signpost.exception.OAuthExpectationFailedException
org.apache.http.client.ClientProtocolException
java.io.IOException
oauth.signpost.exception.OAuthCommunicationExceptionpublic java.lang.String getToken()
public java.lang.String getTokenSecret()
public SoundCloudAPI.State getState()
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||