Package com.google.appengine.api.urlfetch

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


    }
    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


    {
      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

          + "&" + 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

          + "&" + 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

    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)
    {
View Full Code Here

    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 = "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_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_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

   
    @Test
    public void testReadResponseHeaders() throws Exception {
        GHttpEndpoint endpoint = createEndpoint(getBaseUri("ghttp") + "/test");
        HTTPRequest request = new HTTPRequest(endpoint.getEndpointUrl());
        request.addHeader(new HTTPHeader("test", "abc"));
        request.addHeader(new HTTPHeader("content-type", "text/plain"));
        HTTPResponse response = service.fetch(request);
        binding.readResponseHeaders(endpoint, exchange, response);
        assertEquals(200, exchange.getOut().getHeader(Exchange.HTTP_RESPONSE_CODE));
        assertEquals("abc", exchange.getOut().getHeader("test"));
        assertEquals("text/plain", exchange.getOut().getHeader("content-type"));
View Full Code Here

TOP

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

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.