use of com.facebook.GraphRequest in project facebook-android-sdk by facebook.
the class PostsRequest method makePublishPostRequest.
public static void makePublishPostRequest(String message, GraphRequest.Callback callback) {
Bundle params = new Bundle();
params.putString("message", message);
GraphRequest request = new GraphRequest(AccessToken.getCurrentAccessToken(), FEED_ENDPOINT, params, HttpMethod.POST, callback);
request.executeAsync();
}
use of com.facebook.GraphRequest in project facebook-android-sdk by facebook.
the class Utility method getGraphMeRequestWithCache.
private static GraphRequest getGraphMeRequestWithCache(final String accessToken) {
Bundle parameters = new Bundle();
parameters.putString("fields", "id,name,first_name,middle_name,last_name,link");
parameters.putString("access_token", accessToken);
GraphRequest graphRequest = new GraphRequest(null, "me", parameters, HttpMethod.GET, null);
return graphRequest;
}
use of com.facebook.GraphRequest in project facebook-android-sdk by facebook.
the class Utility method getGraphMeRequestWithCacheAsync.
public static void getGraphMeRequestWithCacheAsync(final String accessToken, final GraphMeRequestWithCacheCallback callback) {
JSONObject cachedValue = ProfileInformationCache.getProfileInformation(accessToken);
if (cachedValue != null) {
callback.onSuccess(cachedValue);
return;
}
GraphRequest.Callback graphCallback = new GraphRequest.Callback() {
@Override
public void onCompleted(GraphResponse response) {
if (response.getError() != null) {
callback.onFailure(response.getError().getException());
} else {
ProfileInformationCache.putProfileInformation(accessToken, response.getJSONObject());
callback.onSuccess(response.getJSONObject());
}
}
};
GraphRequest graphRequest = getGraphMeRequestWithCache(accessToken);
graphRequest.setCallback(graphCallback);
graphRequest.executeAsync();
}
use of com.facebook.GraphRequest in project facebook-android-sdk by facebook.
the class Utility method awaitGetGraphMeRequestWithCache.
public static JSONObject awaitGetGraphMeRequestWithCache(final String accessToken) {
JSONObject cachedValue = ProfileInformationCache.getProfileInformation(accessToken);
if (cachedValue != null) {
return cachedValue;
}
GraphRequest graphRequest = getGraphMeRequestWithCache(accessToken);
GraphResponse response = graphRequest.executeAndWait();
if (response.getError() != null) {
return null;
}
return response.getJSONObject();
}
use of com.facebook.GraphRequest in project facebook-android-sdk by facebook.
the class AppEventQueue method sendEventsToServer.
private static FlushStatistics sendEventsToServer(FlushReason reason, AppEventCollection appEventCollection) {
FlushStatistics flushResults = new FlushStatistics();
Context context = FacebookSdk.getApplicationContext();
boolean limitEventUsage = FacebookSdk.getLimitEventAndDataUsage(context);
List<GraphRequest> requestsToExecute = new ArrayList<>();
for (AccessTokenAppIdPair accessTokenAppId : appEventCollection.keySet()) {
GraphRequest request = buildRequestForSession(accessTokenAppId, appEventCollection.get(accessTokenAppId), limitEventUsage, flushResults);
if (request != null) {
requestsToExecute.add(request);
}
}
if (requestsToExecute.size() > 0) {
Logger.log(LoggingBehavior.APP_EVENTS, TAG, "Flushing %d events due to %s.", flushResults.numEvents, reason.toString());
for (GraphRequest request : requestsToExecute) {
// Execute the request synchronously. Callbacks will take care of handling errors
// and updating our final overall result.
request.executeAndWait();
}
return flushResults;
}
return null;
}
Aggregations