private String post() { uploadUrl = "https://upload.twitter.com/1.1/media/upload.json"; HttpParameter[] params = new HttpParameter[1]; try { InputStream is = new FileInputStream(new File(this.photo)); params[0] = new HttpParameter("media", photo, is); postParameter = params; } catch (Exception e) { e.printStackTrace(); } headers.putAll(client.getRequestHeaders()); HttpRequest req = new HttpRequest(RequestMethod.POST, uploadUrl, postParameter, null, headers); String authheader = oauth.getAuthorizationHeader(req); headers.put("Authorization", authheader); HttpRequest req2 = new HttpRequest(RequestMethod.POST, uploadUrl, postParameter, null, headers); try { httpResponse = client.request(req2, null); if (httpResponse.getStatusCode() != 202) { Log.e( "Error from Twitter", "get error in post:" + httpResponse.getStatusCode() + ", details:" + httpResponse.toString()); } return httpResponse.asJSONObject().getString("media_id_string"); } catch (Exception e) { e.printStackTrace(); } return null; }