Exemplo n.º 1
0
    @Override
    protected Void doInBackground(String... params) {
      try {
        List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>(2);
        nameValuePairs.add(
            new BasicNameValuePair("access_token", "059db4f010c5f40bf4a73a28222dd3e3"));
        nameValuePairs.add(new BasicNameValuePair("badge_name", "donorfriend"));
        nameValuePairs.add(new BasicNameValuePair("user_id", auth.getFacebookId()));
        nameValuePairs.add(new BasicNameValuePair("user_token", auth.getAccessToken()));
        JSONObject jsonObject =
            new JSONObject(
                WebUtil.postData(
                    "http://www.itsbeta.com/s/healthcare/donor/achieves/posttofbonce.json",
                    nameValuePairs,
                    "UTF-8"));
        if (!jsonObject.has("error")) {
          Achievement achievement = new Achievement();
          achievement.setDisplayName(jsonObject.getString("display_name"));
          achievement.setPictureLink(jsonObject.getString("pic"));
          achievement.setDescription(jsonObject.getString("desc"));
          startNewAchievementActivity(achievement);
        } else {
          finishBackgroundProcess();
        }
      } catch (Exception e) {

      }
      return null;
    }
Exemplo n.º 2
0
 public void getAchievements(String playerId) throws IOException {
   try {
     JSONObject json = new JSONObject();
     json.put("access_token", "8e6b3a7b47c3346cb7e4db42c88519bc");
     json.put("player_id", playerId);
     json.put("project_id", "50d78a38d870307e9b000002");
     JSONArray jsonArray =
         new JSONArray(
             WebUtil.postData("http://www.itsbeta.com/s/info/achievements.json", json, "UTF-8"));
     if (jsonArray.length() != 1) {
       return;
     }
     JSONArray projects = jsonArray.getJSONObject(0).getJSONArray("projects");
     for (int i = 0; i < projects.length(); i++) {
       JSONObject currentProject = projects.getJSONObject(i);
       Log.d("donor", currentProject.getString("api_name"));
       JSONArray achievements = currentProject.getJSONArray("achievements");
       for (int j = 0; j < achievements.length(); j++) {
         JSONObject currentAchievement = achievements.getJSONObject(i);
         Log.d("donor", currentAchievement.getString("badge_name"));
         Achievement achievement = new Achievement();
         achievement.setDisplayName(currentAchievement.getString("display_name"));
         achievement.setPictureLink(currentAchievement.getString("pic"));
         achievement.setDescription(currentAchievement.getString("desc"));
         achievementsList.add(achievement);
       }
     }
   } catch (Exception e) {
     throw new RuntimeException(e.getMessage());
   }
 }