com.facebook.android
Class Facebook

java.lang.Object
  extended by com.facebook.android.Facebook

public class Facebook
extends Object

THIS CLASS SHOULD BE CONSIDERED DEPRECATED.

All public members of this class are intentionally deprecated. New code should instead use Session to manage session state, Request to make API requests, and WebDialog to make dialog requests.

Adding @Deprecated to this class causes warnings in other deprecated classes that reference this one. That is the only reason this entire class is not deprecated.


Nested Class Summary
static interface Facebook.DialogListener
          Callback interface for dialog requests.
static interface Facebook.ServiceListener
          Callback interface for service requests.
 
Field Summary
static String ATTRIBUTION_ID_COLUMN_NAME
          Deprecated. 
static Uri ATTRIBUTION_ID_CONTENT_URI
          Deprecated. 
static String CANCEL_URI
          Deprecated. 
protected static String DIALOG_BASE_URL
          Deprecated. 
static String EXPIRES
          Deprecated. 
static String FB_APP_SIGNATURE
          Deprecated. 
static int FORCE_DIALOG_AUTH
          Deprecated. 
protected static String GRAPH_BASE_URL
          Deprecated. 
static String REDIRECT_URI
          Deprecated. 
protected static String RESTSERVER_URL
          Deprecated. 
static String SINGLE_SIGN_ON_DISABLED
          Deprecated. 
static String TOKEN
          Deprecated. 
 
Constructor Summary
Facebook(String appId)
          Deprecated. 
 
Method Summary
 void authorize(Activity activity, Facebook.DialogListener listener)
          Deprecated. 
 void authorize(Activity activity, String[] permissions, Facebook.DialogListener listener)
          Deprecated. 
 void authorize(Activity activity, String[] permissions, int activityCode, Facebook.DialogListener listener)
          Deprecated. 
 void authorizeCallback(int requestCode, int resultCode, Intent data)
          Deprecated. 
 void dialog(Context context, String action, Bundle parameters, Facebook.DialogListener listener)
          Deprecated. 
 void dialog(Context context, String action, Facebook.DialogListener listener)
          Deprecated. 
 boolean extendAccessToken(Context context, Facebook.ServiceListener serviceListener)
          Deprecated. 
 boolean extendAccessTokenIfNeeded(Context context, Facebook.ServiceListener serviceListener)
          Deprecated. 
 long getAccessExpires()
          Deprecated. 
 String getAccessToken()
          Deprecated. 
 String getAppId()
          Deprecated. 
static String getAttributionId(ContentResolver contentResolver)
          Deprecated. 
 long getLastAccessUpdate()
          Deprecated. 
 Session getSession()
          Deprecated. 
 boolean getShouldAutoPublishInstall()
          Deprecated. 
 boolean isSessionValid()
          Deprecated. 
 String logout(Context context)
          Deprecated. 
 boolean publishInstall(Context context)
          Deprecated. 
 String request(Bundle parameters)
          Deprecated. 
 String request(String graphPath)
          Deprecated. 
 String request(String graphPath, Bundle parameters)
          Deprecated. 
 String request(String graphPath, Bundle params, String httpMethod)
          Deprecated. 
 void setAccessExpires(long timestampInMsec)
          Deprecated. 
 void setAccessExpiresIn(String expiresInSecsFromNow)
          Deprecated. 
 void setAccessToken(String token)
          Deprecated. 
 void setAppId(String appId)
          Deprecated. 
 void setSession(Session session)
          Deprecated. 
 void setShouldAutoPublishInstall(boolean value)
          Deprecated. 
 void setTokenFromCache(String accessToken, long accessExpires, long lastAccessUpdate)
          Deprecated. 
 boolean shouldExtendAccessToken()
          Deprecated. 
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

REDIRECT_URI

@Deprecated
public static final String REDIRECT_URI
Deprecated. 
See Also:
Constant Field Values

CANCEL_URI

@Deprecated
public static final String CANCEL_URI
Deprecated. 
See Also:
Constant Field Values

TOKEN

@Deprecated
public static final String TOKEN
Deprecated. 
See Also:
Constant Field Values

EXPIRES

@Deprecated
public static final String EXPIRES
Deprecated. 
See Also:
Constant Field Values

SINGLE_SIGN_ON_DISABLED

@Deprecated
public static final String SINGLE_SIGN_ON_DISABLED
Deprecated. 
See Also:
Constant Field Values

ATTRIBUTION_ID_CONTENT_URI

@Deprecated
public static final Uri ATTRIBUTION_ID_CONTENT_URI
Deprecated. 

ATTRIBUTION_ID_COLUMN_NAME

@Deprecated
public static final String ATTRIBUTION_ID_COLUMN_NAME
Deprecated. 
See Also:
Constant Field Values

FORCE_DIALOG_AUTH

@Deprecated
public static final int FORCE_DIALOG_AUTH
Deprecated. 
See Also:
Constant Field Values

DIALOG_BASE_URL

@Deprecated
protected static String DIALOG_BASE_URL
Deprecated. 

GRAPH_BASE_URL

@Deprecated
protected static String GRAPH_BASE_URL
Deprecated. 

RESTSERVER_URL

@Deprecated
protected static String RESTSERVER_URL
Deprecated. 

FB_APP_SIGNATURE

@Deprecated
public static final String FB_APP_SIGNATURE
Deprecated. 
See Also:
Constant Field Values
Constructor Detail

Facebook

@Deprecated
public Facebook(String appId)
Deprecated. 

Constructor for Facebook object.

Parameters:
appId - Your Facebook application ID. Found at www.facebook.com/developers/apps.php.
Method Detail

authorize

@Deprecated
public void authorize(Activity activity,
                                 Facebook.DialogListener listener)
Deprecated. 

Default authorize method. Grants only basic permissions.

See authorize() below for @params.

This method is deprecated. See Facebook and Session for more info.


authorize

@Deprecated
public void authorize(Activity activity,
                                 String[] permissions,
                                 Facebook.DialogListener listener)
Deprecated. 

Authorize method that grants custom permissions.

See authorize() below for @params.

This method is deprecated. See Facebook and Session for more info.


authorize

@Deprecated
public void authorize(Activity activity,
                                 String[] permissions,
                                 int activityCode,
                                 Facebook.DialogListener listener)
Deprecated. 

Full authorize method.

Starts either an Activity or a dialog which prompts the user to log in to Facebook and grant the requested permissions to the given application.

This method will, when possible, use Facebook's single sign-on for Android to obtain an access token. This involves proxying a call through the Facebook for Android stand-alone application, which will handle the authentication flow, and return an OAuth access token for making API calls.

Because this process will not be available for all users, if single sign-on is not possible, this method will automatically fall back to the OAuth 2.0 User-Agent flow. In this flow, the user credentials are handled by Facebook in an embedded WebView, not by the client application. As such, the dialog makes a network request and renders HTML content rather than a native UI. The access token is retrieved from a redirect to a special URL that the WebView handles.

Note that User credentials could be handled natively using the OAuth 2.0 Username and Password Flow, but this is not supported by this SDK.

See http://developers.facebook.com/docs/authentication/ and http://wiki.oauth.net/OAuth-2 for more details.

Note that this method is asynchronous and the callback will be invoked in the original calling thread (not in a background thread).

Also note that requests may be made to the API without calling authorize first, in which case only public information is returned.

IMPORTANT: Note that single sign-on authentication will not function correctly if you do not include a call to the authorizeCallback() method in your onActivityResult() function! Please see below for more information. single sign-on may be disabled by passing FORCE_DIALOG_AUTH as the activityCode parameter in your call to authorize().

This method is deprecated. See Facebook and Session for more info.

Parameters:
activity - The Android activity in which we want to display the authorization dialog.
permissions - A list of permissions required for this application: e.g. "read_stream", "publish_stream", "offline_access", etc. see http://developers.facebook.com/docs/authentication/permissions This parameter should not be null -- if you do not require any permissions, then pass in an empty String array.
activityCode - Single sign-on requires an activity result to be called back to the client application -- if you are waiting on other activities to return data, pass a custom activity code here to avoid collisions. If you would like to force the use of legacy dialog-based authorization, pass FORCE_DIALOG_AUTH for this parameter. Otherwise just omit this parameter and Facebook will use a suitable default. See http://developer.android.com/reference/android/ app/Activity.html for more information.
listener - Callback interface for notifying the calling application when the authentication dialog has completed, failed, or been canceled.

authorizeCallback

@Deprecated
public void authorizeCallback(int requestCode,
                                         int resultCode,
                                         Intent data)
Deprecated. 

IMPORTANT: If you are using the deprecated authorize() method, this method must be invoked at the top of the calling activity's onActivityResult() function or Facebook authentication will not function properly!

If your calling activity does not currently implement onActivityResult(), you must implement it and include a call to this method if you intend to use the authorize() method in this SDK.

For more information, see http://developer.android.com/reference/android/app/ Activity.html#onActivityResult(int, int, android.content.Intent)

This method is deprecated. See Facebook and Session for more info.


extendAccessToken

@Deprecated
public boolean extendAccessToken(Context context,
                                            Facebook.ServiceListener serviceListener)
Deprecated. 

Refresh OAuth access token method. Binds to Facebook for Android stand-alone application application to refresh the access token. This method tries to connect to the Facebook App which will handle the authentication flow, and return a new OAuth access token. This method will automatically replace the old token with a new one. Note that this method is asynchronous and the callback will be invoked in the original calling thread (not in a background thread).

This method is deprecated. See Facebook and Session for more info.

Parameters:
context - The Android Context that will be used to bind to the Facebook RefreshToken Service
serviceListener - Callback interface for notifying the calling application when the refresh request has completed or failed (can be null). In case of a success a new token can be found inside the result Bundle under Facebook.ACCESS_TOKEN key.
Returns:
true if the binding to the RefreshToken Service was created

extendAccessTokenIfNeeded

@Deprecated
public boolean extendAccessTokenIfNeeded(Context context,
                                                    Facebook.ServiceListener serviceListener)
Deprecated. 

Calls extendAccessToken if shouldExtendAccessToken returns true.

This method is deprecated. See Facebook and Session for more info.

Returns:
the same value as extendAccessToken if the the token requires refreshing, true otherwise

shouldExtendAccessToken

@Deprecated
public boolean shouldExtendAccessToken()
Deprecated. 

Check if the access token requires refreshing.

This method is deprecated. See Facebook and Session for more info.

Returns:
true if the last time a new token was obtained was over 24 hours ago.

logout

@Deprecated
public String logout(Context context)
              throws MalformedURLException,
                     IOException
Deprecated. 

Invalidate the current user session by removing the access token in memory, clearing the browser cookie, and calling auth.expireSession through the API.

Note that this method blocks waiting for a network response, so do not call it in a UI thread.

This method is deprecated. See Facebook and Session for more info.

Parameters:
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 cookies
Returns:
JSON string representation of the auth.expireSession response ("true" if successful)
Throws:
IOException
MalformedURLException

request

@Deprecated
public String request(Bundle parameters)
               throws MalformedURLException,
                      IOException
Deprecated. 

Make a request to Facebook's old (pre-graph) API with the given parameters. One of the parameter keys must be "method" and its value should be a valid REST server API method.

See http://developers.facebook.com/docs/reference/rest/

Note that this method blocks waiting for a network response, so do not call it in a UI thread.

Example: Bundle parameters = new Bundle(); parameters.putString("method", "auth.expireSession"); String response = request(parameters);

This method is deprecated. See Facebook and Request for more info.

Parameters:
parameters - Key-value pairs of parameters to the request. Refer to the documentation: one of the parameters must be "method".
Returns:
JSON string representation of the response
Throws:
IOException - if a network error occurs
MalformedURLException - if accessing an invalid endpoint
IllegalArgumentException - if one of the parameters is not "method"

request

@Deprecated
public String request(String graphPath)
               throws MalformedURLException,
                      IOException
Deprecated. 

Make a request to the Facebook Graph API without any parameters.

See http://developers.facebook.com/docs/api

Note that this method blocks waiting for a network response, so do not call it in a UI thread.

This method is deprecated. See Facebook and Request for more info.

Parameters:
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/me
Returns:
JSON string representation of the response
Throws:
IOException
MalformedURLException

request

@Deprecated
public String request(String graphPath,
                                 Bundle parameters)
               throws MalformedURLException,
                      IOException
Deprecated. 

Make a request to the Facebook Graph API with the given string parameters using an HTTP GET (default method).

See http://developers.facebook.com/docs/api

Note that this method blocks waiting for a network response, so do not call it in a UI thread.

This method is deprecated. See Facebook and Request for more info.

Parameters:
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/me
parameters - 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=facebook
Returns:
JSON string representation of the response
Throws:
IOException
MalformedURLException

request

@Deprecated
public String request(String graphPath,
                                 Bundle params,
                                 String httpMethod)
               throws FileNotFoundException,
                      MalformedURLException,
                      IOException
Deprecated. 

Synchronously make a request to the Facebook Graph API with the given HTTP method and string parameters. Note that binary data parameters (e.g. pictures) are not yet supported by this helper function.

See http://developers.facebook.com/docs/api

Note that this method blocks waiting for a network response, so do not call it in a UI thread.

This method is deprecated. See Facebook and Request for more info.

Parameters:
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/me
params - 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=facebook
httpMethod - http verb, e.g. "GET", "POST", "DELETE"
Returns:
JSON string representation of the response
Throws:
IOException
MalformedURLException
FileNotFoundException

dialog

@Deprecated
public void dialog(Context context,
                              String action,
                              Facebook.DialogListener listener)
Deprecated. 

Generate a UI dialog for the request action in the given Android context.

Note that this method is asynchronous and the callback will be invoked in the original calling thread (not in a background thread). This method is deprecated. See WebDialog.

Parameters:
context - The Android context in which we will generate this dialog.
action - String representation of the desired method: e.g. "login", "stream.publish", ...
listener - Callback interface to notify the application when the dialog has completed.

dialog

@Deprecated
public void dialog(Context context,
                              String action,
                              Bundle parameters,
                              Facebook.DialogListener listener)
Deprecated. 

Generate a UI dialog for the request action in the given Android context with the provided parameters.

Note that this method is asynchronous and the callback will be invoked in the original calling thread (not in a background thread). This method is deprecated. See WebDialog.

Parameters:
context - The Android context in which we will generate this dialog.
action - String representation of the desired method: e.g. "feed" ...
parameters - String key-value pairs to be passed as URL parameters.
listener - Callback interface to notify the application when the dialog has completed.

isSessionValid

@Deprecated
public boolean isSessionValid()
Deprecated. 

Returns whether the current access token is valid

Returns:
boolean - whether this object has an non-expired session token

setSession

@Deprecated
public void setSession(Session session)
Deprecated. 

Allows the user to set a Session for the Facebook class to use. If a Session is set here, then one should not use the authorize, logout, or extendAccessToken methods which alter the Session object since that may result in undefined behavior. Using those methods after setting the session here will result in exceptions being thrown.

Parameters:
session - the Session object to use, cannot be null

getSession

@Deprecated
public final Session getSession()
Deprecated. 

Get the underlying Session object to use with 3.0 api.

Returns:
Session - underlying session

getAccessToken

@Deprecated
public String getAccessToken()
Deprecated. 

Retrieve the OAuth 2.0 access token for API access: treat with care. Returns null if no session exists.

Returns:
String - access token

getAccessExpires

@Deprecated
public long getAccessExpires()
Deprecated. 

Retrieve the current session's expiration time (in milliseconds since Unix epoch), or 0 if the session doesn't expire or doesn't exist.

Returns:
long - session expiration time

getLastAccessUpdate

@Deprecated
public long getLastAccessUpdate()
Deprecated. 

Retrieve the last time the token was updated (in milliseconds since the Unix epoch), or 0 if the token has not been set.

Returns:
long - timestamp of the last token update.

setTokenFromCache

@Deprecated
public void setTokenFromCache(String accessToken,
                                         long accessExpires,
                                         long lastAccessUpdate)
Deprecated. 

Restore the token, expiration time, and last update time from cached values. These should be values obtained from getAccessToken(), getAccessExpires, and getLastAccessUpdate() respectively.

This method is deprecated. See Facebook and Session for more info.

Parameters:
accessToken - - access token
accessExpires - - access token expiration time
lastAccessUpdate - - timestamp of the last token update

setAccessToken

@Deprecated
public void setAccessToken(String token)
Deprecated. 

Set the OAuth 2.0 access token for API access.

This method is deprecated. See Facebook and Session for more info.

Parameters:
token - - access token

setAccessExpires

@Deprecated
public void setAccessExpires(long timestampInMsec)
Deprecated. 

Set the current session's expiration time (in milliseconds since Unix epoch), or 0 if the session doesn't expire.

This method is deprecated. See Facebook and Session for more info.

Parameters:
timestampInMsec - - timestamp in milliseconds

setAccessExpiresIn

@Deprecated
public void setAccessExpiresIn(String expiresInSecsFromNow)
Deprecated. 

Set the current session's duration (in seconds since Unix epoch), or "0" if session doesn't expire.

This method is deprecated. See Facebook and Session for more info.

Parameters:
expiresInSecsFromNow - - duration in seconds (or 0 if the session doesn't expire)

getAppId

@Deprecated
public String getAppId()
Deprecated. 

This method is deprecated. See Facebook and Session for more info.

Returns:
the String representing application ID

setAppId

@Deprecated
public void setAppId(String appId)
Deprecated. 

This method is deprecated. See Facebook and Session for more info.

Parameters:
appId - the String representing the application ID

getAttributionId

@Deprecated
public static String getAttributionId(ContentResolver contentResolver)
Deprecated. 

Get Attribution ID for app install conversion tracking.

This method is deprecated. See Facebook and Settings for more info.

Parameters:
contentResolver -
Returns:
Attribution ID that will be used for conversion tracking. It will be null only if the user has not installed or logged in to the Facebook app.

getShouldAutoPublishInstall

@Deprecated
public boolean getShouldAutoPublishInstall()
Deprecated. 

Get the auto install publish setting. If true, an install event will be published during authorize(), unless it has occurred previously or the app does not have install attribution enabled on the application's developer config page.

This method is deprecated. See Facebook and Settings for more info.

Returns:
a Boolean indicating whether installation of the app should be auto-published.

setShouldAutoPublishInstall

@Deprecated
public void setShouldAutoPublishInstall(boolean value)
Deprecated. 

Sets whether auto publishing of installs will occur.

This method is deprecated. See Facebook and Settings for more info.

Parameters:
value - a Boolean indicating whether installation of the app should be auto-published.

publishInstall

@Deprecated
public boolean publishInstall(Context context)
Deprecated. 

Manually publish install attribution to the Facebook graph. Internally handles tracking repeat calls to prevent multiple installs being published to the graph.

This method is deprecated. See Facebook and Settings for more info.

Parameters:
context - the current Android context
Returns:
Always false. Earlier versions of the API returned true if it was no longer necessary to call. Apps should ignore this value, but for compatibility we will return false to ensure repeat calls (and the underlying code will prevent duplicate network traffic).