List of usage examples for java.net MalformedURLException toString
public String toString()
From source file:com.easy.facebook.android.apicall.GraphApi.java
public List<Checkin> searchLocation(String search, String longitude, String latitude, String distance, int limitCheckin) throws EasyFacebookError { int countCheckin = 0; Bundle params = new Bundle(); List<Checkin> checkinList = new ArrayList<Checkin>(); String jsonResponse;//www . java 2 s . co m try { jsonResponse = Util.openUrl( "https://graph.facebook.com/search?q=" + search + "&type=place¢er=" + longitude + "," + latitude + "&distance=" + distance + "&access_token=" + facebook.getAccessToken(), "GET", params); JSONObject objectJSONErrorCheck = new JSONObject(jsonResponse); if (!objectJSONErrorCheck.isNull("error")) { throw new EasyFacebookError(jsonResponse); } JSONObject objectJSON = new JSONObject(jsonResponse); String jsonData = ""; if (!objectJSON.isNull("data")) { jsonData = objectJSON.getString("data").toString(); JSONObjectDecode jsonArray = new JSONObjectDecode(jsonData); for (int i = 0; i < jsonArray.length() && (countCheckin < limitCheckin || limitCheckin < 0); i++) { checkinList.add(jsonArray.getCheckin(i)); countCheckin++; } } } catch (MalformedURLException e) { throw new EasyFacebookError(e.toString(), "MalformedURLException"); } catch (IOException e) { throw new EasyFacebookError(e.toString(), "IOException"); } catch (JSONException e) { throw new EasyFacebookError(e.toString(), "JSONException"); } return checkinList; }
From source file:com.easy.facebook.android.apicall.GraphApi.java
private String createEventsCall(long startTime, long endTime, String name, String urlPicture, String privacy, String description, String location, String street, String city, String state, String country, String latitude, String longitude, String zip) throws EasyFacebookError { String eventID = null;//from w w w . j a v a 2 s . c o m Bundle params = new Bundle(); params.putString("format", "json"); params.putString("access_token", facebook.getAccessToken()); params.putString("start_time", Long.toString(startTime).substring(0, 10)); params.putString("end_time", Long.toString(endTime).substring(0, 10)); params.putString("name", name); params.putString("description", description); params.putString("location", location); params.putString("street", street); params.putString("city", city); params.putString("state", state); params.putString("country", country); params.putString("latitude", latitude); params.putString("longitude", longitude); params.putString("zip", zip); params.putString("privacy", privacy); if (urlPicture != null) { String pictureName = urlPicture.substring(urlPicture.lastIndexOf('/'), urlPicture.length()); params.putByteArray(pictureName, Util.loadPicture(urlPicture)); } try { String jsonResponse = Util.openUrl("https://graph.facebook.com/me/events", "POST", params); JSONObject objectJSONErrorCheck = new JSONObject(jsonResponse); if (!objectJSONErrorCheck.isNull("error")) { throw new EasyFacebookError(jsonResponse); } JSONObject json = new JSONObject(jsonResponse); if (json.has("id")) eventID = json.get("id").toString(); } catch (MalformedURLException e) { throw new EasyFacebookError(e.toString(), "MalformedURLException"); } catch (IOException e) { throw new EasyFacebookError(e.toString(), "IOException"); } catch (JSONException e) { throw new EasyFacebookError(e.toString(), "JSONException"); } return eventID; }
From source file:com.easy.facebook.android.apicall.GraphApi.java
private String postLocation(String message, String friendID, String longitude, String latitude, String pagePlaceID, ArrayList<String> userIdTag) throws EasyFacebookError { String postID = null;//from w ww. j a v a 2 s.c o m Bundle params = new Bundle(); params.putString("format", "json"); params.putString("access_token", facebook.getAccessToken()); params.putString("message", message); params.putString("coordinates", "{\"latitude\": \"" + latitude + "\", \"longitude\": \"" + longitude + "\"}"); params.putString("place", pagePlaceID); String tag = ""; int flagtag = 0; for (String idtag : userIdTag) { tag = tag + "," + idtag; flagtag = 1; } if (flagtag == 1) { tag = tag.substring(1, tag.length()); } params.putString("tags", tag); if (friendID == null) friendID = "me"; try { String jsonResponse = Util.openUrl("https://graph.facebook.com/" + friendID + "/checkins", "POST", params); JSONObject objectJSONErrorCheck = new JSONObject(jsonResponse); if (!objectJSONErrorCheck.isNull("error")) { throw new EasyFacebookError(jsonResponse); } JSONObject json = new JSONObject(jsonResponse); if (json.has("id")) postID = json.get("id").toString(); } catch (MalformedURLException e) { throw new EasyFacebookError(e.toString(), "MalformedURLException"); } catch (IOException e) { throw new EasyFacebookError(e.toString(), "IOException"); } catch (JSONException e) { throw new EasyFacebookError(e.toString(), "JSONException"); } return postID; }
From source file:com.easy.facebook.android.apicall.GraphApi.java
private String postCall(String message, String friendID, String urlPicture, String actionsUrl, String actionsName, String link, String name, String privacy, String countries, String regions, String locales, String description) throws EasyFacebookError { String postID = null;//from w w w . j a v a 2 s . c o m Bundle params = new Bundle(); params.putString("format", "json"); params.putString("access_token", facebook.getAccessToken()); params.putString("message", message); if (description != null) params.putString("description", description); if (actionsUrl != null && actionsName != null) params.putString("actions", "{\"name\": \"" + actionsName + "\", \"link\": \"" + actionsUrl + "\"}"); if (name != null) params.putString("name", name); if (link != null) params.putString("link", link); if (privacy != null) params.putString("privacy", privacy); if (countries != null && regions != null && locales != null) params.putString("targeting", "{\"countries\": \"" + countries + "\", \"regions\": \"" + regions + "\", \"locales\": \"" + locales + "\"}"); if (urlPicture != null) params.putString("picture", urlPicture); if (friendID == null) friendID = "me"; try { String jsonResponse = Util.openUrl("https://graph.facebook.com/" + friendID + "/feed", "POST", params); JSONObject objectJSONErrorCheck = new JSONObject(jsonResponse); if (!objectJSONErrorCheck.isNull("error")) { throw new EasyFacebookError(jsonResponse); } JSONObject json = new JSONObject(jsonResponse); if (json.has("id")) postID = json.get("id").toString(); } catch (MalformedURLException e) { throw new EasyFacebookError(e.toString(), "MalformedURLException"); } catch (IOException e) { throw new EasyFacebookError(e.toString(), "IOException"); } catch (JSONException e) { throw new EasyFacebookError(e.toString(), "JSONException"); } return postID; }
From source file:com.easy.facebook.android.apicall.GraphApi.java
private List<Note> getNoteCall(int limitNote) throws EasyFacebookError { int numArrayElement = 0; int flagNext = 0; String until = ""; int countNote = 0; Bundle params = new Bundle(); params.putString("format", "json"); params.putString("access_token", facebook.getAccessToken()); List<Note> noteList = new ArrayList<Note>(); String jsonResponse;/*from w w w .j a va2 s . c o m*/ try { jsonResponse = Util.openUrl("https://graph.facebook.com/me/notes", "GET", params); JSONObject objectJSONErrorCheck = new JSONObject(jsonResponse); if (!objectJSONErrorCheck.isNull("error")) { throw new EasyFacebookError(jsonResponse); } do { JSONObject objectJSON = new JSONObject(jsonResponse); String jsonData = ""; if (!objectJSON.isNull("data")) { jsonData = objectJSON.getString("data").toString(); JSONObjectDecode jsonArray = new JSONObjectDecode(jsonData); numArrayElement = jsonArray.length(); for (int i = 0; i < jsonArray.length() && (countNote < limitNote || limitNote < 0); i++) { noteList.add(jsonArray.getNote(i)); countNote++; } String paging = ""; if (!objectJSON.isNull("paging")) { paging = objectJSON.getString("paging"); JSONObject objectnextJSON = new JSONObject(paging); String next = ""; if (!objectnextJSON.isNull("next")) { next = objectnextJSON.getString("next").toString(); if (!until.equals( next.substring(next.lastIndexOf("until=") + 6, next.length()).toString()) && (countNote < limitNote || limitNote < 0)) { flagNext = 1; until = next.substring(next.lastIndexOf("until=") + 6, next.length()); params = new Bundle(); params.putString("format", "json"); params.putString("access_token", facebook.getAccessToken()); params.putString("limit", "25"); params.putString("until", until); jsonResponse = Util.openUrl("https://graph.facebook.com/me/notes", "GET", params); objectJSONErrorCheck = new JSONObject(jsonResponse); if (!objectJSONErrorCheck.isNull("error")) { throw new EasyFacebookError(jsonResponse); } } else { flagNext = 0; } } } } } while (flagNext == 1 && numArrayElement > 0 && (countNote < limitNote || limitNote < 0)); } catch (MalformedURLException e) { throw new EasyFacebookError(e.toString(), "MalformedURLException"); } catch (IOException e) { throw new EasyFacebookError(e.toString(), "IOException"); } catch (JSONException e) { throw new EasyFacebookError(e.toString(), "JSONException"); } return noteList; }
From source file:com.easy.facebook.android.apicall.GraphApi.java
private List<Home> getHomeCall(int limitHome) throws EasyFacebookError { int numArrayElement = 0; int flagNext = 0; String until = ""; int countHome = 0; Bundle params = new Bundle(); params.putString("format", "json"); params.putString("access_token", facebook.getAccessToken()); String jsonResponse;// w w w. ja v a2 s . c o m List<Home> homeList = new ArrayList<Home>(); try { jsonResponse = Util.openUrl("https://graph.facebook.com/me/home", "GET", params); JSONObject objectJSONErrorCheck = new JSONObject(jsonResponse); if (!objectJSONErrorCheck.isNull("error")) { throw new EasyFacebookError(jsonResponse); } do { JSONObject objectJSON = new JSONObject(jsonResponse); String jsonData = ""; if (!objectJSON.isNull("data")) { jsonData = objectJSON.getString("data").toString(); JSONObjectDecode jsonArray = new JSONObjectDecode(jsonData); numArrayElement = jsonArray.length(); for (int i = 0; i < jsonArray.length() && (countHome < limitHome || limitHome < 0); i++) { homeList.add(jsonArray.getHome(i)); countHome++; } String paging = ""; if (!objectJSON.isNull("paging")) { paging = objectJSON.getString("paging"); JSONObject objectnextJSON = new JSONObject(paging); String next = ""; if (!objectnextJSON.isNull("next")) { next = objectnextJSON.getString("next").toString(); if (!until.equals( next.substring(next.lastIndexOf("until=") + 6, next.length()).toString()) && (countHome < limitHome || limitHome < 0)) { flagNext = 1; until = next.substring(next.lastIndexOf("until=") + 6, next.length()); params = new Bundle(); params.putString("format", "json"); params.putString("access_token", facebook.getAccessToken()); params.putString("limit", "25"); params.putString("until", until); jsonResponse = Util.openUrl("https://graph.facebook.com/me/home", "GET", params); objectJSONErrorCheck = new JSONObject(jsonResponse); if (!objectJSONErrorCheck.isNull("error")) { throw new EasyFacebookError(jsonResponse); } } else { flagNext = 0; } } } } } while (flagNext == 1 && numArrayElement > 0 && (countHome < limitHome || limitHome < 0)); } catch (MalformedURLException e) { throw new EasyFacebookError(e.toString(), "MalformedURLException"); } catch (IOException e) { throw new EasyFacebookError(e.toString(), "IOException"); } catch (JSONException e) { throw new EasyFacebookError(e.toString(), "JSONException"); } return homeList; }
From source file:com.easy.facebook.android.apicall.GraphApi.java
private List<Message> getInBoxCall(int limitInBox) throws EasyFacebookError { int numArrayElement = 0; int flagNext = 0; String until = ""; int countInBox = 0; Bundle params = new Bundle(); params.putString("format", "json"); params.putString("access_token", facebook.getAccessToken()); String jsonResponse;/*from ww w .j a va 2 s . c o m*/ List<Message> messageList = new ArrayList<Message>(); try { jsonResponse = Util.openUrl("https://graph.facebook.com/me/inbox", "GET", params); JSONObject objectJSONErrorCheck = new JSONObject(jsonResponse); if (!objectJSONErrorCheck.isNull("error")) { throw new EasyFacebookError(jsonResponse); } do { JSONObject objectJSON = new JSONObject(jsonResponse); String jsonData = ""; if (!objectJSON.isNull("data")) { jsonData = objectJSON.getString("data").toString(); JSONObjectDecode jsonArray = new JSONObjectDecode(jsonData); numArrayElement = jsonArray.length(); for (int i = 0; i < jsonArray.length() && (countInBox < limitInBox || limitInBox < 0); i++) { messageList.add(jsonArray.getMessage(i)); countInBox++; } String paging = ""; if (!objectJSON.isNull("paging")) { paging = objectJSON.getString("paging"); JSONObject objectnextJSON = new JSONObject(paging); String next = ""; if (!objectnextJSON.isNull("next")) { next = objectnextJSON.getString("next").toString(); if (!until.equals( next.substring(next.lastIndexOf("until=") + 6, next.length()).toString()) && (countInBox < limitInBox || limitInBox < 0)) { flagNext = 1; until = next.substring(next.lastIndexOf("until=") + 6, next.length()); params = new Bundle(); params.putString("format", "json"); params.putString("access_token", facebook.getAccessToken()); params.putString("limit", "25"); params.putString("until", until); jsonResponse = Util.openUrl("https://graph.facebook.com/me/inbox", "GET", params); objectJSONErrorCheck = new JSONObject(jsonResponse); if (!objectJSONErrorCheck.isNull("error")) { throw new EasyFacebookError(jsonResponse); } } else { flagNext = 0; } } } } } while (flagNext == 1 && numArrayElement > 0 && (countInBox < limitInBox || limitInBox < 0)); } catch (MalformedURLException e) { throw new EasyFacebookError(e.toString(), "MalformedURLException"); } catch (IOException e) { throw new EasyFacebookError(e.toString(), "IOException"); } catch (JSONException e) { throw new EasyFacebookError(e.toString(), "JSONException"); } return messageList; }
From source file:com.easy.facebook.android.apicall.GraphApi.java
private List<Person> getFriendsCall(int limitFriend) throws EasyFacebookError { int numArrayElement = 0; int flagNext = 0; String until = ""; int countEvents = 0; Bundle params = new Bundle(); params.putString("format", "json"); params.putString("access_token", facebook.getAccessToken()); String jsonResponse;// w w w .j a va 2s . c o m List<Person> personList = new ArrayList<Person>(); try { jsonResponse = Util.openUrl("https://graph.facebook.com/me/friends", "GET", params); JSONObject objectJSONErrorCheck = new JSONObject(jsonResponse); if (!objectJSONErrorCheck.isNull("error")) { throw new EasyFacebookError(jsonResponse); } do { JSONObject objectJSON = new JSONObject(jsonResponse); String jsonData = ""; if (!objectJSON.isNull("data")) { jsonData = objectJSON.getString("data").toString(); JSONObjectDecode jsonArray = new JSONObjectDecode(jsonData); numArrayElement = jsonArray.length(); for (int i = 0; i < jsonArray.length() && (countEvents < limitFriend || limitFriend < 0); i++) { personList.add(jsonArray.getPerson(i)); countEvents++; } String paging = ""; if (!objectJSON.isNull("paging")) { paging = objectJSON.getString("paging"); JSONObject objectnextJSON = new JSONObject(paging); String next = ""; if (!objectnextJSON.isNull("next")) { next = objectnextJSON.getString("next").toString(); if (!until.equals( next.substring(next.lastIndexOf("until=") + 6, next.length()).toString()) && (countEvents < limitFriend || limitFriend < 0)) { flagNext = 1; until = next.substring(next.lastIndexOf("until=") + 6, next.length()); params = new Bundle(); params.putString("format", "json"); params.putString("access_token", facebook.getAccessToken()); params.putString("limit", "25"); params.putString("until", until); jsonResponse = Util.openUrl("https://graph.facebook.com/me/friends", "GET", params); objectJSONErrorCheck = new JSONObject(jsonResponse); if (!objectJSONErrorCheck.isNull("error")) { throw new EasyFacebookError(jsonResponse); } } else { flagNext = 0; } } } } } while (flagNext == 1 && numArrayElement > 0 && (countEvents < limitFriend || limitFriend < 0)); } catch (MalformedURLException e) { throw new EasyFacebookError(e.toString(), "MalformedURLException"); } catch (IOException e) { throw new EasyFacebookError(e.toString(), "IOException"); } catch (JSONException e) { throw new EasyFacebookError(e.toString(), "JSONException"); } return personList; }
From source file:com.easy.facebook.android.apicall.GraphApi.java
private List<Person> getEventsResponseCall(String eventId, int limitEvents, String response) throws EasyFacebookError { int numArrayElement = 0; int flagNext = 0; String until = ""; int countEvents = 0; Bundle params = new Bundle(); params.putString("format", "json"); params.putString("access_token", facebook.getAccessToken()); String jsonResponse;// w w w. j a v a2 s. c o m List<Person> personList = new ArrayList<Person>(); try { jsonResponse = Util.openUrl("https://graph.facebook.com/" + eventId + "/" + response, "GET", params); JSONObject objectJSONErrorCheck = new JSONObject(jsonResponse); if (!objectJSONErrorCheck.isNull("error")) { throw new EasyFacebookError(jsonResponse); } do { JSONObject objectJSON = new JSONObject(jsonResponse); String jsonData = ""; if (!objectJSON.isNull("data")) { jsonData = objectJSON.getString("data").toString(); JSONObjectDecode jsonArray = new JSONObjectDecode(jsonData); numArrayElement = jsonArray.length(); for (int i = 0; i < jsonArray.length() && (countEvents < limitEvents || limitEvents < 0); i++) { personList.add(jsonArray.getPerson(i)); countEvents++; } String paging = ""; if (!objectJSON.isNull("paging")) { paging = objectJSON.getString("paging"); JSONObject objectnextJSON = new JSONObject(paging); String next = ""; if (!objectnextJSON.isNull("next")) { next = objectnextJSON.getString("next").toString(); if (!until.equals( next.substring(next.lastIndexOf("until=") + 6, next.length()).toString()) && (countEvents < limitEvents || limitEvents < 0)) { flagNext = 1; until = next.substring(next.lastIndexOf("until=") + 6, next.length()); params = new Bundle(); params.putString("format", "json"); params.putString("access_token", facebook.getAccessToken()); params.putString("limit", "25"); params.putString("until", until); jsonResponse = Util.openUrl( "https://graph.facebook.com/" + eventId + "/" + response, "GET", params); objectJSONErrorCheck = new JSONObject(jsonResponse); if (!objectJSONErrorCheck.isNull("error")) { throw new EasyFacebookError(jsonResponse); } } else { flagNext = 0; } } } } } while (flagNext == 1 && numArrayElement > 0 && (countEvents < limitEvents || limitEvents < 0)); } catch (MalformedURLException e) { throw new EasyFacebookError(e.toString(), "MalformedURLException"); } catch (IOException e) { throw new EasyFacebookError(e.toString(), "IOException"); } catch (JSONException e) { throw new EasyFacebookError(e.toString(), "JSONException"); } return personList; }
From source file:com.easy.facebook.android.apicall.GraphApi.java
private List<Group> getGroupsCall(String friendID, int limitGroups) throws EasyFacebookError { int numArrayElement = 0; int flagNext = 0; String until = ""; int countGroups = 0; Bundle params = new Bundle(); params.putString("format", "json"); params.putString("access_token", facebook.getAccessToken()); if (friendID == null) friendID = "me"; List<Group> groupsList = new ArrayList<Group>(); try {/*from w w w. j av a2s. c o m*/ String jsonResponse = Util.openUrl("https://graph.facebook.com/" + friendID + "/groups", "GET", params); JSONObject objectJSONErrorCheck = new JSONObject(jsonResponse); if (!objectJSONErrorCheck.isNull("error")) { throw new EasyFacebookError(jsonResponse); } do { JSONObject objectJSON = new JSONObject(jsonResponse); String jsonData = ""; if (!objectJSON.isNull("data")) { jsonData = objectJSON.getString("data").toString(); JSONObjectDecode jsonArray = new JSONObjectDecode(jsonData); numArrayElement = jsonArray.length(); for (int i = 0; i < jsonArray.length() && (countGroups < limitGroups || limitGroups < 0); i++) { groupsList.add(jsonArray.getGroup(i)); countGroups++; } String paging = ""; if (!objectJSON.isNull("paging")) { paging = objectJSON.getString("paging"); JSONObject objectnextJSON = new JSONObject(paging); String next = ""; if (!objectnextJSON.isNull("next")) { next = objectnextJSON.getString("next").toString(); if (!until.equals( next.substring(next.lastIndexOf("until=") + 6, next.length()).toString()) && (countGroups < limitGroups || limitGroups < 0)) { flagNext = 1; until = next.substring(next.lastIndexOf("until=") + 6, next.length()); params = new Bundle(); params.putString("format", "json"); params.putString("access_token", facebook.getAccessToken()); params.putString("limit", "25"); params.putString("until", until); jsonResponse = Util.openUrl("https://graph.facebook.com/" + friendID + "/groups", "GET", params); objectJSONErrorCheck = new JSONObject(jsonResponse); if (!objectJSONErrorCheck.isNull("error")) { throw new EasyFacebookError(jsonResponse); } } else { flagNext = 0; } } } } } while (flagNext == 1 && numArrayElement > 0 && (countGroups < limitGroups || limitGroups < 0)); } catch (MalformedURLException e) { throw new EasyFacebookError(e.toString(), "MalformedURLException"); } catch (IOException e) { throw new EasyFacebookError(e.toString(), "IOException"); } catch (JSONException e) { throw new EasyFacebookError(e.toString(), "JSONException"); } return groupsList; }