use of com.facebook.FacebookRequestError in project facebook-android-sdk by facebook.
the class PlacesGraphSDKHelper method provideCurrentPlaceFeedback.
/**
* Creates and executes a current place feedback request. This request is used to provide
* feedback on the accuracy of the current place response.
*
* @param currentPlaceResult The result of the current place request.
* @param place The place where the user is (or isn't') located.
* @param wasHere true to indicate that the user is located at the place, and
* false to indicate that the user is not located at the place.
*/
public static void provideCurrentPlaceFeedback(final CurrentPlaceResult currentPlaceResult, final Place place, final boolean wasHere) {
// Creates the builder of the current place feedback request.
CurrentPlaceFeedbackRequestParams.Builder builder = new CurrentPlaceFeedbackRequestParams.Builder();
/**
* Sets the tracking ID, which is used as a correlator to the current place response.
* The tracking ID is retrieved from the current place response.
*/
builder.setTracking(currentPlaceResult.getTracking());
// The place at which the user is (or is not) located.
String placeId = place.get(Place.ID);
builder.setPlaceId(placeId);
// Indicates if the user is or is not at the place.
builder.setWasHere(wasHere);
GraphRequest request = PlaceManager.newCurrentPlaceFeedbackRequest(builder.build());
GraphRequest.Callback callback = new GraphRequest.Callback() {
@Override
public void onCompleted(GraphResponse response) {
boolean success = false;
FacebookRequestError error = response.getError();
if (error == null) {
JSONObject jsonObject = response.getJSONObject();
success = jsonObject.optBoolean("success");
} else {
Log.d(TAG, "response error: " + error);
}
Log.d(TAG, "provideCurrentPlaceFeedback: onCompleted: response: success=" + success);
}
};
request.setCallback(callback);
request.executeAsync();
}
use of com.facebook.FacebookRequestError in project FirebaseUI-Android by firebase.
the class FacebookProvider method onSuccess.
@Override
public void onSuccess(final LoginResult loginResult) {
GraphRequest request = GraphRequest.newMeRequest(loginResult.getAccessToken(), new GraphRequest.GraphJSONObjectCallback() {
@Override
public void onCompleted(JSONObject object, GraphResponse response) {
FacebookRequestError requestError = response.getError();
if (requestError != null) {
Log.e(TAG, "Received Facebook error: " + requestError.getErrorMessage());
onFailure(new Bundle());
return;
}
if (object == null) {
Log.w(TAG, "Received null response from Facebook GraphRequest");
onFailure(new Bundle());
} else {
try {
String email = object.getString("email");
onSuccess(email, loginResult);
} catch (JSONException e) {
Log.e(TAG, "JSON Exception reading from Facebook GraphRequest", e);
onFailure(new Bundle());
}
}
}
});
Bundle parameters = new Bundle();
parameters.putString("fields", "id,name,email");
request.setParameters(parameters);
request.executeAsync();
}
use of com.facebook.FacebookRequestError in project openkit-android by OpenKit.
the class OKSocialLeaderboardFragment method getSocialScoresFromOpenKit.
private void getSocialScoresFromOpenKit() {
if (FacebookUtilities.isFBSessionOpen()) {
startedSocialRequest();
FacebookUtilities.GetFBFriends(new GetFBFriendsRequestHandler() {
@Override
public void onSuccess(ArrayList<Long> friendsArray) {
currentLeaderboard.getFacebookFriendsScoresWithFacebookFriends(friendsArray, new OKScoresResponseHandler() {
@Override
public void onSuccess(List<OKScore> scoresList) {
OKLog.v("Got %d social scores!", scoresList.size());
addScoresToSocialScoresListAdapater(scoresList);
stoppedSocialRequest();
}
@Override
public void onFailure(Throwable e, JSONObject errorResponse) {
OKLog.v("Failed to get social scores from OpenKit: " + e);
stoppedSocialRequest();
}
});
}
@Override
public void onFail(FacebookRequestError error) {
OKLog.v("Failed to get Facebook friends");
stoppedSocialRequest();
}
});
}
}
use of com.facebook.FacebookRequestError in project openkit-android by OpenKit.
the class ScoreCreator method CreateGlobalScores.
public static void CreateGlobalScores(int aNumScores, int aLeaderboardID, final int maxScoreValue) {
final int numScores = aNumScores;
final int leaderboardID = aLeaderboardID;
OKLog.d("Getting list of FB friends");
Session session = Session.getActiveSession();
if (session != null && session.isOpened()) {
Request friendsRequest = Request.newMyFriendsRequest(session, new GraphUserListCallback() {
@Override
public void onCompleted(List<GraphUser> users, Response response) {
FacebookRequestError error = response.getError();
if (error != null) {
OKLog.d("Error getting Facebook friends");
// requestHandler.onFail(error);
} else {
OKLog.d("Got %d facebook friends", users.size());
Random generator = new Random();
for (int x = 0; x < numScores; x++) {
int friendIndex = generator.nextInt(users.size());
CreateScoreForFBUser(users.get(friendIndex), leaderboardID, x, maxScoreValue);
}
}
}
});
friendsRequest.executeAsync();
} else {
OKLog.v("FB session not open");
}
}
use of com.facebook.FacebookRequestError in project openkit-android by OpenKit.
the class ScoreCreator method CreateFriendsScores.
public static void CreateFriendsScores(int aNumScores, int aLeaderboardID, int maxScoreValue) {
final int numScores = aNumScores;
final int leaderboardID = aLeaderboardID;
OKLog.d("Getting list of FB friends");
Session session = Session.getActiveSession();
if (session != null && session.isOpened()) {
Request friendsRequest = Request.newMyFriendsRequest(session, new GraphUserListCallback() {
@Override
public void onCompleted(List<GraphUser> users, Response response) {
FacebookRequestError error = response.getError();
if (error != null) {
OKLog.d("Error getting Facebook friends");
} else {
OKLog.d("Got %d facebook friends", users.size());
Random generator = new Random();
for (int x = 0; x < numScores; x++) {
int friendIndex = generator.nextInt(users.size());
CreateFriendScore(users.get(friendIndex), leaderboardID, x);
}
}
}
});
friendsRequest.executeAsync();
} else {
OKLog.v("FB session not open");
}
}
Aggregations