Facebook Developers
DocsToolsSupportNewsApps
Log In
  • Social Plugins
  • Facebook Login
  • Open Graph
  • Facebook APIs
  • Games
  • Payments
  • App Center
  • Promote Your App
  • iOS
  • Android
  • JavaScript
  • PHP
  • More SDKs
  • Methods
    • API Requests
    • Async API Requests
    • Authentication
    • Dialogs
    • Helpers
  • Interfaces
    • -
    • DialogListener
  • Errors
    • DialogError
    • FacebookError

API Requests

The API request methods used in the Facebook Android SDK. These are defined in Facebook.java.

You implement these methods to do the following:

  • Make a server request using the Graph API.

  • Make a server request using FQL.

  • Make a server request using the Legacy REST API.

Request Methods


String request(String graphPath) throws MalformedURLException, IOException:

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

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.

Exceptions

MalformedURLException - if accessing an invalid endpoint

IOException - if a network error occurs

Return Value

JSON string representation of the response

Notes

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


String request(String graphPath, Bundle parameters) throws MalformedURLException, IOException:

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

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

Exceptions

MalformedURLException - if accessing an invalid endpoint

IOException - if a network error occurs

Return Value

JSON string representation of the response

Notes

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


String request(String graphPath, Bundle parameters, String httpMethod) throws MalformedURLException, IOException:

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.

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

httpMethod - http verb, e.g. "GET", "POST", "DELETE"

Exceptions

MalformedURLException - if accessing an invalid endpoint

IOException - if a network error occurs

Return Value

JSON string representation of the response

Notes

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


String request(Bundle parameters) throws MalformedURLException, IOException:

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

Parameters

parameters - Key-value pairs of parameters to the request. Refer to the documentation: one of the parameters must be "method". Example:

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

Exceptions

IOException - if a network error occurs

MalformedURLException - if accessing an invalid endpoint

IllegalArgumentException - if one of the parameters is not "method"

Return Value

JSON string representation of the response

Notes

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

Updated over a year ago
Facebook © 2013 · English (US)
AboutAdvertisingCareersPlatform PoliciesPrivacy Policy