Package com.google.appengine.api.urlfetch

Examples of com.google.appengine.api.urlfetch.HTTPRequest


    params = "POST&" + URLEncoder.encode(url.toString(),"UTF-8")
          + "&" + URLEncoder.encode(params,"UTF-8");
    String sig = generateSignature(params,oauth_token_secret);
   
    String authorization = generateAuthString(timestamp, nonce, sig);
    HTTPRequest request = new HTTPRequest(url,HTTPMethod.POST);
    request.addHeader(new HTTPHeader("Authorization",authorization));
    request.addHeader(new HTTPHeader("Content-Type","application/x-www-form-urlencoded"));
   
    String strPayload = "id=" + id;
    request.setPayload(strPayload.getBytes());
    URLFetchService service = URLFetchServiceFactory.getURLFetchService();
    HTTPResponse response = service.fetch(request);
   
    return response;
  }
View Full Code Here


   
    params = "GET&" + URLEncoder.encode(url.toString(),"UTF-8")
          + "&" + URLEncoder.encode(params,"UTF-8");
    String sig = generateSignature(params,oauth_token_secret);
    String authorization = generateAuthString(timestamp, nonce, sig);
    HTTPRequest request;
    if(pageID == null)
    {
      request = new HTTPRequest(url,HTTPMethod.GET);
    }
    else
    {
      request = new HTTPRequest(new URL(url.toString() + "?page=" + pageID),HTTPMethod.GET);
    }
    request.addHeader(new HTTPHeader("Authorization",authorization));
    URLFetchService service = URLFetchServiceFactory.getURLFetchService();
    HTTPResponse response = service.fetch(request);
    return response;
  }
View Full Code Here

    }
    params = "GET&" + URLEncoder.encode(strurl,"UTF-8")
        + "&" + URLEncoder.encode(params,"UTF-8");
    String sig = generateSignature(params,oauth_token_secret);
    String authorization = generateAuthString(timestamp, nonce, sig);
    HTTPRequest request;
    if(pageID != null)
    {
      strurl = strurl + "?page=" + pageID;
    }
    if(since_id != null)
    {
      strurl = strurl + "?since_id=" + since_id;
    }
    URL url = new URL(strurl);
    request = new HTTPRequest(url,HTTPMethod.GET);
    request.addHeader(new HTTPHeader("Authorization",authorization));
    URLFetchService service = URLFetchServiceFactory.getURLFetchService();
    HTTPResponse response = service.fetch(request);
   
    return response;
  }
View Full Code Here

    String params = generateParams(timestamp,nonce);
    params = "GET&" + URLEncoder.encode(url.toString(),"UTF-8")
          + "&" + URLEncoder.encode(params,"UTF-8");
    String sig = generateSignature(params,oauth_token_secret);
    String authorization = generateAuthString(timestamp, nonce, sig);
    HTTPRequest request;
    request = new HTTPRequest(url,HTTPMethod.GET);
    request.addHeader(new HTTPHeader("Authorization",authorization));
    URLFetchService service = URLFetchServiceFactory.getURLFetchService();
    HTTPResponse response = service.fetch(request);
    return response;
  }
View Full Code Here

    params = "id=" + id  + "&" + generateParams(timestamp,nonce);
    params = "GET&" + URLEncoder.encode(url.toString(),"UTF-8")
          + "&" + URLEncoder.encode(params,"UTF-8");
    String sig = generateSignature(params,oauth_token_secret);
    String authorization = generateAuthString(timestamp, nonce, sig);
    HTTPRequest request;
    request = new HTTPRequest(new URL(url.toString() + "?id=" + id),HTTPMethod.GET);
    request.addHeader(new HTTPHeader("Authorization",authorization));
    URLFetchService service = URLFetchServiceFactory.getURLFetchService();
    HTTPResponse response = service.fetch(request);
    return response;
  }
View Full Code Here

          + "&" + URLEncoder.encode(params,"UTF-8");
    params = Common.replaceEncode(params);
   
    String sig = generateSignature(params,oauth_token_secret);
    String authorization = generateAuthString(timestamp, nonce, sig);
    HTTPRequest request = new HTTPRequest(url,HTTPMethod.POST);
    request.addHeader(new HTTPHeader("Authorization",authorization));
    request.addHeader(new HTTPHeader("Content-Type","application/x-www-form-urlencoded"));
   
    String strPayload;
    strPayload = "status=" + URLEncoder.encode(strMessage,"UTF-8");
    if(replyID != null && userID != null)
    {
      strPayload = strPayload + "&in_reply_to_status_id=" + replyID + "&in_reply_to_user_id=" + userID;
    }
    if(repostID != null)
    {
      strPayload = strPayload + "&repost_status_id=" + repostID;
    }
    request.setPayload(strPayload.getBytes());
    URLFetchService service = URLFetchServiceFactory.getURLFetchService();
    HTTPResponse response = service.fetch(request);
   
    return response;
  }
View Full Code Here

    params = "GET&" + URLEncoder.encode(strURL,"UTF-8")
          + "&" + URLEncoder.encode(params,"UTF-8");

    String sig = generateSignature(params,oauth_token_secret);
    String authorization = generateAuthString(timestamp, nonce, sig);
    HTTPRequest request;

    if(userID == null && pageID == null)
    {
      request = new HTTPRequest(new URL(strURL),HTTPMethod.GET);
    }
    else if(userID == null && pageID != null)
    {
      strURL = strURL + "?page=" + pageID;

    }
    else if(userID != null && pageID == null)
    {
      strURL = strURL + "?id=" + userID;
    }
    else if(userID != null && pageID != null)
    {
      strURL = strURL + "?id=" + userID + "&page=" + pageID;
    }
    request = new HTTPRequest(new URL(strURL),HTTPMethod.GET);
    request.addHeader(new HTTPHeader("Authorization",authorization));
    URLFetchService service = URLFetchServiceFactory.getURLFetchService();
    HTTPResponse response = service.fetch(request);
    return response;
  }
View Full Code Here

    params = "id=" + id + "&" + generateParams(timestamp,nonce);
    params = "GET&" + URLEncoder.encode(url.toString(),"UTF-8")
          + "&" + URLEncoder.encode(params,"UTF-8");
    String sig = generateSignature(params,oauth_token_secret);
    String authorization = generateAuthString(timestamp, nonce, sig);
    HTTPRequest request = new HTTPRequest(new URL(url.toString() + "?id=" + id),HTTPMethod.GET);
    request.addHeader(new HTTPHeader("Authorization",authorization));
    URLFetchService service = URLFetchServiceFactory.getURLFetchService();
    HTTPResponse response = service.fetch(request);
   
    return response;
  }
View Full Code Here

          + ",oauth_nonce=\"" + String.valueOf(nonce) + "\""
          + ",oauth_signature=\"" + sig + "\""
          + ",oauth_token=\"" + oauth_token + "\""
          + ",oauth_verifier=\"" + strPIN + "\"";

    HTTPRequest request = new HTTPRequest(url,HTTPMethod.GET);
    request.addHeader(new HTTPHeader("Authorization",authorization));
    URLFetchService service = URLFetchServiceFactory.getURLFetchService();
    HTTPResponse response = service.fetch(request);
   
    if(response.getResponseCode() == 200)
    {
View Full Code Here

      strBuf.append(",oauth_timestamp=\"").append(timestamp).append("\"");
      strBuf.append(",oauth_nonce=\"").append(nonce).append("\"");
      strBuf.append(",oauth_signature=\"").append(sig).append("\"");
      authorization = strBuf.toString();
     
      HTTPRequest request = new HTTPRequest(url,HTTPMethod.GET);
      request.addHeader(new HTTPHeader("Authorization",authorization));
      URLFetchService service = URLFetchServiceFactory.getURLFetchService();
      HTTPResponse response;
      try {
        response = service.fetch(request);
      } catch (SocketTimeoutException e) {
        Common.sendMessage(fromJID, "连接饭否超时,请重试");
        return;
      }
      if(response.getResponseCode() != 200)
      {
        String errMsg = "出现错误,请重试";
        Common.sendMessage(fromJID,errMsg);
        Common.log.warning(strJID + " :" + String.valueOf(response.getResponseCode()) + ": " + new String(response.getContent()));
        return;
      }
     
      /* 提取接收到的未经授权的Request Token */
      String tokenstring = new String(response.getContent());
      String[] tokenarr = tokenstring.split("&");
      String[] tokenarr2 = tokenarr[0].split("=");
      String oauth_token = tokenarr2[1];
      Common.setData(fromJID,"Account","request_token",oauth_token);
     
      /* 请求用户授权Request Token */
      String strMessage = "请访问以下网址获取PIN码: \n http://fanfou.com/oauth/authorize?oauth_token="
            + oauth_token + "&oauth_callback=oob"
            + " \n 手机用户请访问: \n http://m.fanfou.com/oauth/authorize?oauth_token="
            + oauth_token + "&oauth_callback=oob"
            + " \n 然后使用\"-bind PIN码\"命令绑定账号。";
      Common.sendMessage(fromJID,strMessage);
    }
    else if(msgarr.length == 3)                        //XAuth
    {
      URL url = new URL("http://fanfou.com/oauth/access_token");
      String username = msgarr[1];
      String password = msgarr[2];
      params = "oauth_consumer_key=" + API.consumer_key
          + "&oauth_nonce=" + String.valueOf(nonce)
          + "&oauth_signature_method=HMAC-SHA1"
          + "&oauth_timestamp=" + String.valueOf(timestamp)
          + "&x_auth_username=" + username
          + "&x_auth_password=" + password
          + "&x_auth_mode=client_auth";
   
      params = "GET&" + URLEncoder.encode(url.toString(),"UTF-8")
            + "&" + URLEncoder.encode(params,"UTF-8");
      String sig = API.generateSignature(params);
     
      authorization = "OAuth realm=\"Fantalker\",oauth_consumer_key=\"" + API.consumer_key
            + "\",oauth_signature_method=\"HMAC-SHA1\""
            + ",oauth_timestamp=\"" + String.valueOf(timestamp) + "\""
            + ",oauth_nonce=\"" + String.valueOf(nonce) + "\""
            + ",oauth_signature=\"" + sig + "\""
            + ",x_auth_username=\"" + username + "\""
            + ",x_auth_password=\"" + password + "\""
            + ",x_auth_mode=\"client_auth\"";
     
     
      HTTPRequest request = new HTTPRequest(url,HTTPMethod.GET);
      request.addHeader(new HTTPHeader("Authorization",authorization));
      URLFetchService service = URLFetchServiceFactory.getURLFetchService();
      HTTPResponse response;
      try {
        response = service.fetch(request);
      } catch (SocketTimeoutException e) {
View Full Code Here

TOP

Related Classes of com.google.appengine.api.urlfetch.HTTPRequest

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.