コード例 #1
0
 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;
 }
コード例 #2
0
 @Override
 public int hashCode() {
   int result = client != null ? client.hashCode() : 0;
   result = 31 * result + (conf != null ? conf.hashCode() : 0);
   result = 31 * result + (apiKey != null ? apiKey.hashCode() : 0);
   result = 31 * result + (oauth != null ? oauth.hashCode() : 0);
   result = 31 * result + (uploadUrl != null ? uploadUrl.hashCode() : 0);
   result = 31 * result + (postParameter != null ? Arrays.hashCode(postParameter) : 0);
   result = 31 * result + (appendParameter != null ? Arrays.hashCode(appendParameter) : 0);
   result = 31 * result + (photo != null ? photo.hashCode() : 0);
   result = 31 * result + (message != null ? message.hashCode() : 0);
   result = 31 * result + (headers != null ? headers.hashCode() : 0);
   result = 31 * result + (httpResponse != null ? httpResponse.hashCode() : 0);
   return result;
 }
コード例 #3
0
  @Override
  public boolean equals(Object o) {
    if (this == o) return true;
    if (o == null || getClass() != o.getClass()) return false;

    AbstractPhotoUploadImpl that = (AbstractPhotoUploadImpl) o;

    if (apiKey != null ? !apiKey.equals(that.apiKey) : that.apiKey != null) return false;
    if (!Arrays.equals(appendParameter, that.appendParameter)) return false;
    if (client != null ? !client.equals(that.client) : that.client != null) return false;
    if (conf != null ? !conf.equals(that.conf) : that.conf != null) return false;
    if (headers != null ? !headers.equals(that.headers) : that.headers != null) return false;
    if (httpResponse != null ? !httpResponse.equals(that.httpResponse) : that.httpResponse != null)
      return false;
    if (photo != null ? !photo.equals(that.photo) : that.photo != null) return false;
    if (message != null ? !message.equals(that.message) : that.message != null) return false;
    if (oauth != null ? !oauth.equals(that.oauth) : that.oauth != null) return false;
    if (!Arrays.equals(postParameter, that.postParameter)) return false;
    if (uploadUrl != null ? !uploadUrl.equals(that.uploadUrl) : that.uploadUrl != null)
      return false;

    return true;
  }