FacebookOperationCanceledException error in Facebook game sample SDK Friend Smash

5

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

  

Please check your network connection - FacebookOperationCanceledException error

Before that he was already logged in and presented the name and photo without any problems after accepting the game permission request on my facebook.

At log.cat it presented the following error:

  

01-31 13: 25: 36.791: E / FriendSmash (5312): org.json.JSONException: Value false of type java.lang.Boolean can not be converted to JSONArray

Looking for solution, I found the following lines where 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, because the example already has http://www.friendsmash.com/ , but I did not set it when I created the application in Facebook developer . This application already exists on Facebook, can this 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 in Facebook developer .

    
asked by anonymous 31.01.2014 / 21:31

1 answer

1

Two questions:

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

  • Your test user allowed both your app and to the Friends Smash app (I do not know what, do not even have one, but I strongly believe so) )? And if so, did you ever post any score before trying to read them?

    I decided to test the URL of the tutorial, and by passing my User ID and an Temporary Access Token , I also received false response. I also tried posting a score to see if that solved the problem (doing POST with my fbid , access_token and score ), and received the following response: "No user with fbid 1331462558 found". I searched the rest of the tutorial for a way to register, but I did not find it.

    (I found this application , which looks like the Friend Smash sample, but I solved do not give permission to send me emails or post on my name just to answer a question in SOPT, sorry!)

    That is, I believe that the reason for him being false is because either you are not registered and / or because you never posted a score. Your parameters are correct (otherwise you would see an error message) and are valid (otherwise you would see null ), hence I conclude that false is part of the friendsmash.com same site logic, does not seem to be anything wrong that you did not ...

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

      

    An initial question is whether this url is created automatically, since the example already has the link , but I did not set it when I created the application on Facebook developer. This application already exists on Facebook, can this cause conflict?

    I think it's not necessary (and maybe even impossible) to set it that way, because the server function according to the tutorial itself is "post and fetch scores from your own server to create a scoreboard ". friendsmash.com , if still active, should do just that, without requiring any further integration of your application with it. Notice the following lines:

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

    When you do this you are giving User Access Token to it, and tokens are portable , that's all that friendsmash.com needs to act on your user name (ie read and modify data from it). Needless to say, this is a security issue (aggravated by the fact that the token is passed via GET without the use of HTTPS ), but in the context of the specific problem it means that there is nothing missing for the Friend Smash site to act. / p>

    Note: the token gives as much access as it had when it was created; for example, when I did that test earlier, I ensured that the token would only be valid for 60 minutes and I 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 from your app and passing it to friendsmash.com , so it will have the same permissions as your app has . In this particular case, I do not think there is anything malicious, but in practice it is good to be very careful about what a token contains before sharing it with other sites (as this directly affects the privacy of your users / clients strong>).

        
    06.02.2014 / 09:02