use of twitter4j.JSONException in project twitter4j by yusuke.
the class MobypictureUpload method postUpload.
@Override
protected String postUpload() throws TwitterException {
int statusCode = httpResponse.getStatusCode();
if (statusCode != 200)
throw new TwitterException("Mobypic image upload returned invalid status code", httpResponse);
String response = httpResponse.asString();
try {
JSONObject json = new JSONObject(response);
if (!json.isNull("media")) {
return json.getJSONObject("media").getString("mediaurl");
}
} catch (JSONException e) {
throw new TwitterException("Invalid Mobypic response: " + response, e);
}
throw new TwitterException("Unknown Mobypic response", httpResponse);
}
use of twitter4j.JSONException in project twitter4j by yusuke.
the class ImgLyUpload method postUpload.
@Override
protected String postUpload() throws TwitterException {
int statusCode = httpResponse.getStatusCode();
if (statusCode != 200)
throw new TwitterException("ImgLy image upload returned invalid status code", httpResponse);
String response = httpResponse.asString();
try {
JSONObject json = new JSONObject(response);
if (!json.isNull("url"))
return json.getString("url");
} catch (JSONException e) {
throw new TwitterException("Invalid ImgLy response: " + response, e);
}
throw new TwitterException("Unknown ImgLy response", httpResponse);
}
Aggregations