Esempio n. 1
0
  public static String encodeUrl(WeiboParameters parameters) {
    if (parameters == null) {
      return "";
    }

    StringBuilder sb = new StringBuilder();
    boolean first = true;
    for (int loc = 0; loc < parameters.size(); loc++) {
      if (first) {
        first = false;
      } else {
        sb.append("&");
      }
      String _key = parameters.getKey(loc);
      String _value = parameters.getValue(_key);
      if (_value == null) {
        Log.i("encodeUrl", "key:" + _key + " 's value is null");
      } else {
        sb.append(
            URLEncoder.encode(parameters.getKey(loc))
                + "="
                + URLEncoder.encode(parameters.getValue(loc)));
      }
    }
    return sb.toString();
  }
Esempio n. 2
0
  protected String requestSync(
      final String url, final WeiboParameters params, final String httpMethod)
      throws WeiboException {
    params.add("access_token", mAccessToken);

    System.out.println("requestSync mAccessToken = " + mAccessToken);

    Log.d("WeiboAPI", "requestSync request " + url);
    String resp = HttpManager.openUrl(url, httpMethod, params, params.getValue("pic"));
    Log.d("WeiboAPI", "requestSync request " + resp);
    return resp;
  }
Esempio n. 3
0
 public static String encodeParameters(WeiboParameters httpParams) {
   if (null == httpParams || isBundleEmpty(httpParams)) {
     return "";
   }
   StringBuilder buf = new StringBuilder();
   int j = 0;
   for (int loc = 0; loc < httpParams.size(); loc++) {
     String key = httpParams.getKey(loc);
     if (j != 0) {
       buf.append("&");
     }
     try {
       buf.append(URLEncoder.encode(key, "UTF-8"))
           .append("=")
           .append(URLEncoder.encode(httpParams.getValue(key), "UTF-8"));
     } catch (java.io.UnsupportedEncodingException neverHappen) {
     }
     j++;
   }
   return buf.toString();
 }