Advertisement
Guest User

Untitled

a guest
Jul 23rd, 2017
126
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.97 KB | None | 0 0
  1.     @RequestMapping(value = "token",method = RequestMethod.POST, produces = "text/plain")
  2.     public ResponseEntity<String> authorize(@RequestParam String secret, @RequestParam String accountKey, @RequestParam String login, @RequestParam String appKey){
  3.         String url = "http://a.wykop.pl/user/login/appkey,"+appKey;
  4.  
  5.  
  6.         String apisign = AuthComponent.getMD5Hash(secret, url, accountKey, login);
  7.         HttpHeaders headers = new HttpHeaders();
  8.         headers.add("apisign", apisign);
  9.         headers.setContentType(MediaType.APPLICATION_FORM_URLENCODED); //to jest wymagane ewentualnie multipart też przejdzie
  10.  
  11.         MultiValueMap<String, String> map= new LinkedMultiValueMap<String, String>(); //by móc wysłać urlencoeded, map nie przejdzie
  12.  
  13.         map.add("accountkey", accountKey);
  14.         map.add("login", login);
  15.  
  16.         HttpEntity<?> request = new HttpEntity<>(map, headers);
  17.  
  18.         return restTemplate.postForEntity(url, request, String.class);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement