Package 

Object GraphRequest.Companion

    • Method Detail

      • getDefaultBatchApplicationId

         final String getDefaultBatchApplicationId()

        Gets the default Facebook application ID that will be used to submit batched requests. Batched requests require an application ID, so either at least one request in a batch must provide an access token or the application ID must be specified explicitly.

      • setDefaultBatchApplicationId

         final Unit setDefaultBatchApplicationId(String applicationId)

        Sets the default application ID that will be used to submit batched requests if none of those requests specifies an access token. Batched requests require an application ID, so either at least one request in a batch must specify an access token or the application ID must be specified explicitly.

        Parameters:
        applicationId - the Facebook application ID to use for batched requests if none can be determined
      • newDeleteObjectRequest

         final GraphRequest newDeleteObjectRequest(AccessToken accessToken, String id, GraphRequest.Callback callback)

        Creates a new Request configured to delete a resource through the Graph API.

        Parameters:
        accessToken - the access token to use, or null
        id - the id of the object to delete
        callback - a callback that will be called when the request is completed to handle success or error conditions
      • newMeRequest

         final GraphRequest newMeRequest(AccessToken accessToken, GraphRequest.GraphJSONObjectCallback callback)

        Creates a new Request configured to retrieve a user's own profile.

        Parameters:
        accessToken - the access token to use, or null
        callback - a callback that will be called when the request is completed to handle success or error conditions
      • newPostRequest

         final GraphRequest newPostRequest(AccessToken accessToken, String graphPath, JSONObject graphObject, GraphRequest.Callback callback)

        Creates a new Request configured to post a GraphObject to a particular graph path, to either create or update the object at that path.

        Parameters:
        accessToken - the access token to use, or null
        graphPath - the graph path to retrieve, create, or delete
        graphObject - the graph object to create or update
        callback - a callback that will be called when the request is completed to handle success or error conditions
      • newGraphPathRequest

         final GraphRequest newGraphPathRequest(AccessToken accessToken, String graphPath, GraphRequest.Callback callback)

        Creates a new Request configured to retrieve a particular graph path.

        Parameters:
        accessToken - the access token to use, or null
        graphPath - the graph path to retrieve
        callback - a callback that will be called when the request is completed to handle success or error conditions
      • newPlacesSearchRequest

         final GraphRequest newPlacesSearchRequest(AccessToken accessToken, Location location, Integer radiusInMeters, Integer resultsLimit, String searchText, GraphRequest.GraphJSONArrayCallback callback)

        Creates a new Request that is configured to perform a search for places near a specified location via the Graph API. At least one of location or searchText must be specified.

        Parameters:
        accessToken - the access token to use, or null
        location - the location around which to search; only the latitude and longitude components of the location are meaningful
        radiusInMeters - the radius around the location to search, specified in meters; this is ignored if no location is specified
        resultsLimit - the maximum number of results to return
        searchText - optional text to search for as part of the name or type of an object
        callback - a callback that will be called when the request is completed to handle success or error conditions
      • newUploadPhotoRequest

         final GraphRequest newUploadPhotoRequest(AccessToken accessToken, String graphPath, Bitmap image, String caption, Bundle params, GraphRequest.Callback callback)

        Creates a new Request configured to upload a photo to the specified graph path.

        Parameters:
        accessToken - the access token to use, or null
        graphPath - the graph path to use, defaults to me/photos
        image - the bitmap image to upload
        caption - the user generated caption for the photo, can be null
        params - the parameters, can be null
        callback - a callback that will be called when the request is completed to handle success or error conditions, can be null
      • newUploadPhotoRequest

         final GraphRequest newUploadPhotoRequest(AccessToken accessToken, String graphPath, File file, String caption, Bundle params, GraphRequest.Callback callback)

        Creates a new Request configured to upload a photo to the specified graph path. The photo will be read from the specified file.

        Parameters:
        accessToken - the access token to use, or null
        graphPath - the graph path to use, defaults to me/photos
        file - the file containing the photo to upload
        caption - the user generated caption for the photo, can be null
        params - the parameters, can be null
        callback - a callback that will be called when the request is completed to handle success or error conditions, can be null
      • newUploadPhotoRequest

         final GraphRequest newUploadPhotoRequest(AccessToken accessToken, String graphPath, Uri photoUri, String caption, Bundle params, GraphRequest.Callback callback)

        Creates a new Request configured to upload a photo to the specified graph path. The photo will be read from the specified Uri.

        Parameters:
        accessToken - the access token to use, or null
        graphPath - the graph path to use, defaults to me/photos
        photoUri - the file:// or content:// Uri to the photo on device
        caption - the user generated caption for the photo, can be null
        params - the parameters, can be null
        callback - a callback that will be called when the request is completed to handle success or error conditions, can be null
      • newCustomAudienceThirdPartyIdRequest

         final GraphRequest newCustomAudienceThirdPartyIdRequest(AccessToken accessToken, Context context, String applicationId, GraphRequest.Callback callback)

        Creates a new Request configured to retrieve an App User ID for the app's Facebook user. Callers will send this ID back to their own servers, collect up a set to create a Facebook Custom Audience with, and then use the resultant Custom Audience to target ads.

        The GraphObject in the response will include a "custom_audience_third_party_id" property, with the value being the ID retrieved. This ID is an encrypted encoding of the Facebook user's ID and the invoking Facebook app ID. Multiple calls with the same user will return different IDs, thus these IDs cannot be used to correlate behavior across devices or applications, and are only meaningful when sent back to Facebook for creating Custom Audiences.

        The ID retrieved represents the Facebook user identified in the following way: if the specified access token (or active access token if null) is valid, the ID will represent the user associated with the active access token; otherwise the ID will represent the user logged into the native Facebook app on the device. A null ID will be provided into the callback if a) there is no native Facebook app, b) no one is logged into it, or c) the app has previously called FacebookSdk.setLimitEventAndDataUsage ;} with true for this user. You must call this method from a background thread for it to work properly.

        Parameters:
        accessToken - the access token to issue the Request on, or null If there is no logged-in Facebook user, null is the expected choice.
        context - the Application context from which the app ID will be pulled, and from which the 'attribution ID' for the Facebook user is determined.
        applicationId - explicitly specified Facebook App ID.
        callback - a callback that will be called when the request is completed to handle success or error conditions.
      • newCustomAudienceThirdPartyIdRequest

         final GraphRequest newCustomAudienceThirdPartyIdRequest(AccessToken accessToken, Context context, GraphRequest.Callback callback)

        Creates a new Request configured to retrieve an App User ID for the app's Facebook user. Callers will send this ID back to their own servers, collect up a set to create a Facebook Custom Audience with, and then use the resultant Custom Audience to target ads.

        The GraphObject in the response will include a "custom_audience_third_party_id" property, with the value being the ID retrieved. This ID is an encrypted encoding of the Facebook user's ID and the invoking Facebook app ID. Multiple calls with the same user will return different IDs, thus these IDs cannot be used to correlate behavior across devices or applications, and are only meaningful when sent back to Facebook for creating Custom Audiences.

        The ID retrieved represents the Facebook user identified in the following way: if the specified access token (or active access token if null) is valid, the ID will represent the user associated with the active access token; otherwise the ID will represent the user logged into the native Facebook app on the device. A null ID will be provided into the callback if a) there is no native Facebook app, b) no one is logged into it, or c) the app has previously called FacebookSdk.setLimitEventAndDataUsage with true for this user. You must call this method from a background thread for it to work properly.

        Parameters:
        accessToken - the access token to issue the Request on, or null If there is no logged-in Facebook user, null is the expected choice.
        context - the Application context from which the app ID will be pulled, and from which the 'attribution ID' for the Facebook user is determined.
        callback - a callback that will be called when the request is completed to handle success or error conditions.
      • toHttpConnection

         final HttpURLConnection toHttpConnection(GraphRequest requests)

        Serializes one or more requests but does not execute them. The resulting HttpURLConnection can be executed explicitly by the caller.

        Parameters:
        requests - one or more Requests to serialize
      • toHttpConnection

         final HttpURLConnection toHttpConnection(Collection<GraphRequest> requests)

        Serializes one or more requests but does not execute them. The resulting HttpURLConnection can be executed explicitly by the caller.

        Parameters:
        requests - one or more Requests to serialize
      • toHttpConnection

         final HttpURLConnection toHttpConnection(GraphRequestBatch requests)

        Serializes one or more requests but does not execute them. The resulting HttpURLConnection can be executed explicitly by the caller.

        Parameters:
        requests - a RequestBatch to serialize
      • executeAndWait

         final GraphResponse executeAndWait(GraphRequest request)

        Executes a single request on the current thread and blocks while waiting for the response.

        This should only be used if you have transitioned off the UI thread.

        Parameters:
        request - the Request to execute
      • executeBatchAndWait

         final List<GraphResponse> executeBatchAndWait(GraphRequest requests)

        Executes requests on the current thread as a single batch and blocks while waiting for the response.

        This should only be used if you have transitioned off the UI thread.

        Parameters:
        requests - the Requests to execute
      • executeBatchAndWait

         final List<GraphResponse> executeBatchAndWait(Collection<GraphRequest> requests)

        Executes requests as a single batch on the current thread and blocks while waiting for the responses.

        This should only be used if you have transitioned off the UI thread.

        Parameters:
        requests - the Requests to execute
      • executeBatchAndWait

         final List<GraphResponse> executeBatchAndWait(GraphRequestBatch requests)

        Executes requests on the current thread as a single batch and blocks while waiting for the responses.

        This should only be used if you have transitioned off the UI thread.

        Parameters:
        requests - the batch of Requests to execute
      • executeBatchAsync

         final GraphRequestAsyncTask executeBatchAsync(GraphRequest requests)

        Executes requests as a single batch asynchronously. This function will return immediately, and the requests will be processed on a separate thread. In order to process results of a request, or determine whether a request succeeded or failed, a callback must be specified (see the .setCallback method).

        This should only be called from the UI thread.

        Parameters:
        requests - the Requests to execute
      • executeBatchAsync

         final GraphRequestAsyncTask executeBatchAsync(Collection<GraphRequest> requests)

        Executes requests as a single batch asynchronously. This function will return immediately, and the requests will be processed on a separate thread. In order to process results of a request, or determine whether a request succeeded or failed, a callback must be specified (see the .setCallback method).

        This should only be called from the UI thread.

        Parameters:
        requests - the Requests to execute
      • executeBatchAsync

         final GraphRequestAsyncTask executeBatchAsync(GraphRequestBatch requests)

        Executes requests as a single batch asynchronously. This function will return immediately, and the requests will be processed on a separate thread. In order to process results of a request, or determine whether a request succeeded or failed, a callback must be specified (see the .setCallback method).

        This should only be called from the UI thread.

        Parameters:
        requests - the RequestBatch to execute
      • executeConnectionAndWait

         final List<GraphResponse> executeConnectionAndWait(HttpURLConnection connection, Collection<GraphRequest> requests)

        Executes requests that have already been serialized into an HttpURLConnection. No validation is done that the contents of the connection actually reflect the serialized requests, so it is the caller's responsibility to ensure that it will correctly generate the desired responses.

        This should only be called if you have transitioned off the UI thread.

        Parameters:
        connection - the HttpURLConnection that the requests were serialized into
        requests - the requests represented by the HttpURLConnection
      • executeConnectionAndWait

         final List<GraphResponse> executeConnectionAndWait(HttpURLConnection connection, GraphRequestBatch requests)

        Executes requests that have already been serialized into an HttpURLConnection. No validation is done that the contents of the connection actually reflect the serialized requests, so it is the caller's responsibility to ensure that it will correctly generate the desired responses.

        This should only be called if you have transitioned off the UI thread.

        Parameters:
        connection - the HttpURLConnection that the requests were serialized into
        requests - the RequestBatch represented by the HttpURLConnection
      • executeConnectionAsync

         final GraphRequestAsyncTask executeConnectionAsync(HttpURLConnection connection, GraphRequestBatch requests)

        Asynchronously executes requests that have already been serialized into an HttpURLConnection. No validation is done that the contents of the connection actually reflect the serialized requests, so it is the caller's responsibility to ensure that it will correctly generate the desired responses. This function will return immediately, and the requests will be processed on a separate thread. In order to process results of a request, or determine whether a request succeeded or failed, a callback must be specified (see the .setCallback method).

        This should only be called from the UI thread.

        Parameters:
        connection - the HttpURLConnection that the requests were serialized into
        requests - the requests represented by the HttpURLConnection
      • executeConnectionAsync

         final GraphRequestAsyncTask executeConnectionAsync(Handler callbackHandler, HttpURLConnection connection, GraphRequestBatch requests)

        Asynchronously executes requests that have already been serialized into an HttpURLConnection. No validation is done that the contents of the connection actually reflect the serialized requests, so it is the caller's responsibility to ensure that it will correctly generate the desired responses. This function will return immediately, and the requests will be processed on a separate thread. In order to process results of a request, or determine whether a request succeeded or failed, a callback must be specified (see the .setCallback method)

        This should only be called from the UI thread.

        Parameters:
        callbackHandler - a Handler that will be used to post calls to the callback for each request; if null, a Handler will be instantiated on the calling thread
        connection - the HttpURLConnection that the requests were serialized into
        requests - the requests represented by the HttpURLConnection
      • getMAXIMUM_BATCH_SIZE

         final Integer getMAXIMUM_BATCH_SIZE()

        The maximum number of requests that can be submitted in a single batch. This limit is enforced on the service side by the Facebook platform, not by the Request class.