@Override public void onCompleted(GraphResponse response) { final JSONObject data = response.getJSONObject(); final String postId = (data == null ? null : data.optString("id")); ShareInternalUtility.invokeCallbackWithResults(callback, postId, response); } };
@Override protected void processSuccess(GraphResponse response) { JSONArray dataSet = Utility.tryGetJSONArrayFromResponse( response.getJSONObject(), "data"); if (dataSet != null && dataSet.length() > 0) { objectIsLiked = true; } }
@Override public void onCompleted(GraphResponse response) { if (callback != null) { JSONObject result = response.getJSONObject(); JSONArray data = result != null ? result.optJSONArray("data") : null; callback.onCompleted(data, response); } } };
@Override public void onCompleted(GraphResponse response) { JSONObject data = response.getJSONObject(); if (data == null) { return; } refreshResult.accessToken = data.optString("access_token"); refreshResult.expiresAt = data.optInt("expires_at"); refreshResult.dataAccessExpirationTime = data.optLong("data_access_expiration_time"); } })
@Override public void onCompleted(GraphResponse response) { if (callback != null) { callback.onCompleted(response.getJSONObject(), response); } } };
@Override public void onCompleted(GraphResponse response) { if (callback != null) { JSONObject result = response.getJSONObject(); JSONArray data = result != null ? result.optJSONArray("data") : null; callback.onCompleted(data, response); } } };
@Override public void onCompleted(GraphResponse response) { final JSONObject data = response.getJSONObject(); final String postId = (data == null ? null : data.optString("id")); ShareInternalUtility.invokeCallbackWithResults(callback, postId, response); } };
@Override protected void processSuccess(GraphResponse response) { JSONObject results = Utility.tryGetJSONObjectFromResponse( response.getJSONObject(), objectId); if (results != null) { verifiedObjectId = results.optString("id"); objectIsPage = !Utility.isNullOrEmpty(verifiedObjectId); } }
private static JSONObject getAppSettingsQueryResponse(String applicationId) { Bundle appSettingsParams = new Bundle(); ArrayList<String> appSettingFields = new ArrayList<>(Arrays.asList(APP_SETTING_FIELDS)); if (BuildConfig.DEBUG) { appSettingFields.add(SDK_UPDATE_MESSAGE); } appSettingsParams.putString(APPLICATION_FIELDS, TextUtils.join(",", appSettingFields)); GraphRequest request = GraphRequest.newGraphPathRequest(null, applicationId, null); request.setSkipClientToken(true); request.setParameters(appSettingsParams); return request.executeAndWait().getJSONObject(); }
private static @Nullable JSONObject getAppGateKeepersQueryResponse(final String applicationId) { Bundle appGateKeepersParams = new Bundle(); appGateKeepersParams.putString(APPLICATION_PLATFORM, APP_PLATFORM); appGateKeepersParams.putString(APPLICATION_SDK_VERSION, FacebookSdk.getSdkVersion()); appGateKeepersParams.putString(APPLICATION_FIELDS, APPLICATION_GATEKEEPER_FIELD); GraphRequest request = GraphRequest.newGraphPathRequest(null, String.format("%s/%s", applicationId, APPLICATION_GATEKEEPER_EDGE), null); request.setSkipClientToken(true); request.setParameters(appGateKeepersParams); return request.executeAndWait().getJSONObject(); }
@Override protected void performAsserts(GraphResponse response) { assertNotNull(response); JSONObject retrievedPhoto = response.getJSONObject(); assertNotNull(retrievedPhoto); assertEquals(image2Size, retrievedPhoto.optInt("width")); } });
@Override protected void performAsserts(GraphResponse response) { assertNotNull(response); JSONObject retrievedPhoto = response.getJSONObject(); assertNotNull(retrievedPhoto); assertEquals(image1Size, retrievedPhoto.optInt("width")); } });
@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()); } } };
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(); }
protected JSONObject batchPostAndGet(GraphRequest post, GraphRequest get) { List<GraphResponse> responses = GraphRequest.executeBatchAndWait(post, get); assertEquals(2, responses.size()); JSONObject resultGraphObject = responses.get(1).getJSONObject(); assertNotNull(resultGraphObject); return resultGraphObject; }
protected JSONObject getAndAssert(AccessToken accessToken, String id) { Bundle parameters = new Bundle(); parameters.putString("fields", "message"); GraphRequest request = new GraphRequest(accessToken, id, parameters, null); GraphResponse response = request.executeAndWait(); assertNotNull(response); assertNull(response.getError()); JSONObject result = response.getJSONObject(); assertNotNull(result); return result; }
@LargeTest public void testExplicitDependencyDefaultsToOmitFirstResponse() { final AccessToken accessToken = getAccessTokenForSharedUser(); GraphRequest requestMe = GraphRequest.newMeRequest(accessToken, null); requestMe.setBatchEntryName("me_request"); GraphRequest requestMyFriends = GraphRequest.newMyFriendsRequest(accessToken, null); requestMyFriends.setBatchEntryDependsOn("me_request"); List<GraphResponse> responses = GraphRequest.executeBatchAndWait(requestMe, requestMyFriends); GraphResponse meResponse = responses.get(0); GraphResponse myFriendsResponse = responses.get(1); assertNull(meResponse.getJSONObject()); assertNotNull(myFriendsResponse.getJSONObject()); }
protected JSONObject postGetAndAssert(AccessToken accessToken, String path, JSONObject graphObject) { GraphRequest request = GraphRequest.newPostRequest(accessToken, path, graphObject, null); GraphResponse response = request.executeAndWait(); assertNotNull(response); assertNull(response.getError()); JSONObject result = response.getJSONObject(); assertNotNull(result); assertNotNull(result.optString("id")); return getAndAssert(accessToken, result.optString("id")); }
static void validateMeResponse(AccessToken accessToken, GraphResponse response) { assertNull(response.getError()); JSONObject me = response.getJSONObject(); assertNotNull(me); assertEquals(accessToken.getUserId(), me.optString("id")); assertNotNull(response.getRawResponse()); }
static void validateMyFriendsResponse(GraphResponse response) { assertNotNull(response); assertNull(response.getError()); JSONObject graphResult = response.getJSONObject(); assertNotNull(graphResult); JSONArray results = graphResult.optJSONArray("data"); assertNotNull(results); assertNotNull(response.getRawResponse()); }