|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.netmera.facebook.AsyncFacebookRunner
public class AsyncFacebookRunner
A sample implementation of asynchronous API requests. This class provides the ability to execute API methods and have the call return immediately, without blocking the calling thread. This is necessary when accessing the API in the UI thread, for instance. The request response is returned to the caller via a callback interface, which the developer must implement. This sample implementation simply spawns a new thread for each request, and makes the API call immediately. This may work in many applications, but more sophisticated users may re-implement this behavior using a thread pool, a network thread, a request queue, or other mechanism. Advanced functionality could be built, such as rate-limiting of requests, as per a specific application's needs.
The callback interface.
Nested Class Summary | |
---|---|
static interface |
AsyncFacebookRunner.RequestListener
Callback interface for API requests. |
Constructor Summary | |
---|---|
AsyncFacebookRunner(Facebook fb)
|
Method Summary | |
---|---|
void |
logout(android.content.Context context,
AsyncFacebookRunner.RequestListener listener)
|
void |
logout(android.content.Context context,
AsyncFacebookRunner.RequestListener listener,
java.lang.Object state)
Invalidate the current user session by removing the access token in memory, clearing the browser cookies, and calling auth.expireSession through the API. |
void |
request(android.os.Bundle parameters,
AsyncFacebookRunner.RequestListener listener)
|
void |
request(android.os.Bundle parameters,
AsyncFacebookRunner.RequestListener listener,
java.lang.Object state)
Make a request to Facebook's old (pre-graph) API with the given parameters. |
void |
request(java.lang.String graphPath,
AsyncFacebookRunner.RequestListener listener)
|
void |
request(java.lang.String graphPath,
AsyncFacebookRunner.RequestListener listener,
java.lang.Object state)
Make a request to the Facebook Graph API without any parameters. |
void |
request(java.lang.String graphPath,
android.os.Bundle parameters,
AsyncFacebookRunner.RequestListener listener)
|
void |
request(java.lang.String graphPath,
android.os.Bundle parameters,
AsyncFacebookRunner.RequestListener listener,
java.lang.Object state)
Make a request to the Facebook Graph API with the given string parameters using an HTTP GET (default method). |
void |
request(java.lang.String graphPath,
android.os.Bundle parameters,
java.lang.String httpMethod,
AsyncFacebookRunner.RequestListener listener,
java.lang.Object state)
Make a request to the Facebook Graph API with the given HTTP method and string parameters. |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public AsyncFacebookRunner(Facebook fb)
Method Detail |
---|
public void logout(android.content.Context context, AsyncFacebookRunner.RequestListener listener, java.lang.Object state)
context
- The Android context in which the logout should be called: it
should be the same context in which the login occurred in
order to clear any stored cookieslistener
- Callback interface to notify the application when the request
has completed.state
- An arbitrary object used to identify the request when it
returns to the callback. This has no effect on the request
itself.public void logout(android.content.Context context, AsyncFacebookRunner.RequestListener listener)
public void request(android.os.Bundle parameters, AsyncFacebookRunner.RequestListener listener, java.lang.Object state)
Bundle parameters = new Bundle();
parameters.putString("method", "auth.expireSession", new Listener());
String response = request(parameters);
parameters
- Key-value pairs of parameters to the request. Refer to the
documentation: one of the parameters must be "method".listener
- Callback interface to notify the application when the request
has completed.state
- An arbitrary object used to identify the request when it
returns to the callback. This has no effect on the request
itself.public void request(android.os.Bundle parameters, AsyncFacebookRunner.RequestListener listener)
public void request(java.lang.String graphPath, AsyncFacebookRunner.RequestListener listener, java.lang.Object state)
graphPath
- Path to resource in the Facebook graph, e.g., to fetch data
about the currently logged authenticated user, provide "me",
which will fetch http://graph.facebook.com/melistener
- Callback interface to notify the application when the request
has completed.state
- An arbitrary object used to identify the request when it
returns to the callback. This has no effect on the request
itself.public void request(java.lang.String graphPath, AsyncFacebookRunner.RequestListener listener)
public void request(java.lang.String graphPath, android.os.Bundle parameters, AsyncFacebookRunner.RequestListener listener, java.lang.Object state)
graphPath
- Path to resource in the Facebook graph, e.g., to fetch data
about the currently logged authenticated user, provide "me",
which will fetch http://graph.facebook.com/meparameters
- key-value string parameters, e.g. the path "search" with
parameters "q" : "facebook" would produce a query for the
following graph resource:
https://graph.facebook.com/search?q=facebooklistener
- Callback interface to notify the application when the request
has completed.state
- An arbitrary object used to identify the request when it
returns to the callback. This has no effect on the request
itself.public void request(java.lang.String graphPath, android.os.Bundle parameters, AsyncFacebookRunner.RequestListener listener)
public void request(java.lang.String graphPath, android.os.Bundle parameters, java.lang.String httpMethod, AsyncFacebookRunner.RequestListener listener, java.lang.Object state)
graphPath
- Path to resource in the Facebook graph, e.g., to fetch data
about the currently logged authenticated user, provide "me",
which will fetch http://graph.facebook.com/meparameters
- key-value string parameters, e.g. the path "search" with
parameters {"q" : "facebook"} would produce a query for the
following graph resource:
https://graph.facebook.com/search?q=facebookhttpMethod
- http verb, e.g. "POST", "DELETE"listener
- Callback interface to notify the application when the request
has completed.state
- An arbitrary object used to identify the request when it
returns to the callback. This has no effect on the request
itself.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |