Facebookoperationcanceledexception error in Facebook SDK Friend Smash example game

Asked

Viewed 164 times

5

I followed the tutorial from Facebook SDK to implement the game Friend Smash. In Activity Home has a button to view the Scores. However, when clicking it shows a connection error on the screen:

Please check your network Connection -- Facebookoperationcanceledexception error

Before that he was already logged in to the user, and presented without problems the name and the photo after accepting the request for permission of the game on my facebook.

In log.cat he presented the following error:

01-31 13:25:36.791: E/friendsmash(5312): org.json.Jsonexception: Value false of type java.lang.Boolean cannot be converted to Jsonarray

Searching solution, I found the following lines where the problem happened. The string getURL returns FALSE.

// Get the attributes used for the HTTP GET
String currentUserFBID = application.getCurrentFBUser().getId();
String currentUserAccessToken = Session.getActiveSession().getAccessToken();

// Execute the HTTP Get to our server for the scores of the user's friends
HttpClient client = new DefaultHttpClient();
String getURL = "http://www.friendsmash.com/scores?fbid=" + currentUserFBID + "&access_token=" + currentUserAccessToken;
HttpGet get = new HttpGet(getURL);
HttpResponse responseGet = client.execute(get);

// Parse the response
HttpEntity responseEntity = responseGet.getEntity();
String response = EntityUtils.toString(responseEntity);
JSONArray responseJSONArray = new JSONArray(response);

An initial question is whether this url is created automatically, as the example already brings the http://www.friendsmash.com/, but I didn’t set this when I created the app on Facebook. This application already exists on Facebook, this can cause conflict?

Any solution? The code is the same as the one downloaded from the tutorial and I followed the tutorial for creating a new application on Facebook.

1 answer

1


Two questions:

  1. Are you running a recent version of the tutorial? I searched Github for the code posted, and found it nowhere (nor on friendsmash_complete nor in the friendsmash_incomplete). If your code is an older revision, it is possible that the API has changed.

  2. Your test user allowed so much your app how much the Friends Smash app (I don’t know what it is, I don’t even have one, but I strongly believe so)? And if so, you did post some score before trying to read them?

    I decided to test the tutorial URL, and while passing my User ID and a Temporary Access Token, also received as a reply false. I also tried to post a score to see if this would solve the problem (making a POST with my fbid, access_token and a score), and received the following reply: "No user with fbid 1331462558 found". I searched the rest of the tutorial for a way to register, but could not find.

    (found this app, that looks like Friend Smash sample, but I solved not give permission for him to send me emails or publish in my name just to answer a question in SOPT, Sorry!).

    I mean, I believe the reason he’s returning false is either because you are not registered and/or because you have never posted a score. Your parameters are correct (otherwise you would see an error message) and are valid (otherwise you would see null), I therefore conclude that the false is part of the logic of the site friendsmash.com even, it doesn’t seem to me to be anything wrong that you have done no...

In my opinion, these are the most probable causes of your mistake (the 2nd more than the 1st), because:

An initial question is whether this url is created automatically, as the example already brings the http://www.friendsmash.com/, but I did not put this when I created the app on Facebook. This app already exists on Facebook, it may cause conflict?

I believe that it is not necessary (and maybe not possible) to set it this way, because the function of the server according to the tutorial itself is "post and search Scores from your own server to create a scoreboard". The friendsmash.com, if still active, you should do just that, without requiring any additional integration of your application with it. Note the following lines:

String currentUserAccessToken = Session.getActiveSession().getAccessToken();
...
String getURL = "http://www.friendsmash.com/scores?fbid=" + currentUserFBID + "&access_token=" + currentUserAccessToken;

When you do that you are giving their User Access Token for him, and how tokens are portable, that’s all the friendsmash.com need to act on your user name (i.e. read and modify your user data). Needless to say, this is a security problem (aggravated by the fact that the token is passed via GET without the use of HTTPS), but in the context of the specific problem means that there is nothing missing for the Friend Smash site to act.

Note: the token gives as much access as it had when it was created; for example, when I did that test earlier, I made sure that the token would only be valid for 60 minutes and did not give any permission beyond the most basic ones (see my name, photo and friends list). In your case, it seems to me that you are extracting the token granted to your app and going over it at the friendsmash.com, so that it will have the same permissions that your app has. In this particular case, I don’t think there’s anything malicious, but in practice it’s good to be very careful about what a token contains before you share it with other sites (because it directly affects privacy of their users/customers).

Browser other questions tagged

You are not signed in. Login or sign up in order to post.