Search in sources :

Example 1 with Request

use of com.facebook.Request in project facebook-api-android-maven by avianey.

the class Utility method queryAppSettings.

// Note that this method makes a synchronous Graph API call, so should not be called from the main thread.
public static FetchedAppSettings queryAppSettings(final String applicationId, final boolean forceRequery) {
    // Cache the last app checked results.
    if (!forceRequery && fetchedAppSettings.containsKey(applicationId)) {
        return fetchedAppSettings.get(applicationId);
    }
    Bundle appSettingsParams = new Bundle();
    appSettingsParams.putString(APPLICATION_FIELDS, TextUtils.join(",", APP_SETTING_FIELDS));
    Request request = Request.newGraphPathRequest(null, applicationId, null);
    request.setParameters(appSettingsParams);
    GraphObject supportResponse = request.executeAndWait().getGraphObject();
    FetchedAppSettings result = new FetchedAppSettings(safeGetBooleanFromResponse(supportResponse, SUPPORTS_ATTRIBUTION), safeGetBooleanFromResponse(supportResponse, SUPPORTS_IMPLICIT_SDK_LOGGING), safeGetStringFromResponse(supportResponse, NUX_CONTENT), safeGetBooleanFromResponse(supportResponse, NUX_ENABLED));
    fetchedAppSettings.put(applicationId, result);
    return result;
}
Also used : Bundle(android.os.Bundle) Request(com.facebook.Request) GraphObject(com.facebook.model.GraphObject)

Example 2 with Request

use of com.facebook.Request in project facebook-api-android-maven by avianey.

the class FriendPickerFragment method createRequest.

private Request createRequest(String userID, Set<String> extraFields, Session session) {
    Request request = Request.newGraphPathRequest(session, userID + friendPickerType.getRequestPath(), null);
    Set<String> fields = new HashSet<String>(extraFields);
    String[] requiredFields = new String[] { ID, NAME };
    fields.addAll(Arrays.asList(requiredFields));
    String pictureField = adapter.getPictureFieldSpecifier();
    if (pictureField != null) {
        fields.add(pictureField);
    }
    Bundle parameters = request.getParameters();
    parameters.putString("fields", TextUtils.join(",", fields));
    request.setParameters(parameters);
    return request;
}
Also used : Bundle(android.os.Bundle) Request(com.facebook.Request)

Example 3 with Request

use of com.facebook.Request in project Klyph by jonathangerbaud.

the class FriendPickerFragment method createRequest.

private Request createRequest(String userID, Set<String> extraFields, Session session) {
    Request request = Request.newGraphPathRequest(session, userID + "/friends", null);
    Set<String> fields = new HashSet<String>(extraFields);
    String[] requiredFields = new String[] { ID, NAME };
    fields.addAll(Arrays.asList(requiredFields));
    String pictureField = adapter.getPictureFieldSpecifier();
    if (pictureField != null) {
        fields.add(pictureField);
    }
    Bundle parameters = request.getParameters();
    parameters.putString("fields", TextUtils.join(",", fields));
    request.setParameters(parameters);
    return request;
}
Also used : Bundle(android.os.Bundle) Request(com.facebook.Request)

Example 4 with Request

use of com.facebook.Request in project Klyph by jonathangerbaud.

the class LoginButton method fetchUserInfo.

private void fetchUserInfo() {
    if (fetchUserInfo) {
        final Session currentSession = sessionTracker.getOpenSession();
        if (currentSession != null) {
            if (currentSession != userInfoSession) {
                Request request = Request.newMeRequest(currentSession, new Request.GraphUserCallback() {

                    @Override
                    public void onCompleted(GraphUser me, Response response) {
                        if (currentSession == sessionTracker.getOpenSession()) {
                            user = me;
                            if (userInfoChangedCallback != null) {
                                userInfoChangedCallback.onUserInfoFetched(user);
                            }
                        }
                        if (response.getError() != null) {
                            handleError(response.getError().getException());
                        }
                    }
                });
                Request.executeBatchAsync(request);
                userInfoSession = currentSession;
            }
        } else {
            user = null;
            if (userInfoChangedCallback != null) {
                userInfoChangedCallback.onUserInfoFetched(user);
            }
        }
    }
}
Also used : Response(com.facebook.Response) GraphUser(com.facebook.model.GraphUser) Request(com.facebook.Request) Session(com.facebook.Session)

Example 5 with Request

use of com.facebook.Request in project phonegap-facebook-plugin by Wizcorp.

the class FriendPickerFragment method createRequest.

private Request createRequest(String userID, Set<String> extraFields, Session session) {
    Request request = Request.newGraphPathRequest(session, userID + friendPickerType.getRequestPath(), null);
    Set<String> fields = new HashSet<String>(extraFields);
    String[] requiredFields = new String[] { ID, NAME };
    fields.addAll(Arrays.asList(requiredFields));
    String pictureField = adapter.getPictureFieldSpecifier();
    if (pictureField != null) {
        fields.add(pictureField);
    }
    Bundle parameters = request.getParameters();
    parameters.putString("fields", TextUtils.join(",", fields));
    request.setParameters(parameters);
    return request;
}
Also used : Bundle(android.os.Bundle) Request(com.facebook.Request)

Aggregations

Request (com.facebook.Request)13 Bundle (android.os.Bundle)8 Response (com.facebook.Response)4 Session (com.facebook.Session)4 GraphObject (com.facebook.model.GraphObject)3 GraphUser (com.facebook.model.GraphUser)3 FacebookRequestError (com.facebook.FacebookRequestError)2 GraphUserListCallback (com.facebook.Request.GraphUserListCallback)2 Random (java.util.Random)2 GraphUserCallback (com.facebook.Request.GraphUserCallback)1 UnsupportedEncodingException (java.io.UnsupportedEncodingException)1 HashSet (java.util.HashSet)1