Advertisement
Guest User

Untitled

a guest
Oct 7th, 2015
110
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.07 KB | None | 0 0
  1. global class IpdReqDev {
  2. String url;
  3. String data;
  4. String token{get;set;}
  5. Public String mytext {get;set;}
  6. public IpdReqDev() {
  7. url = 'some landing api url/index.php?action=api';
  8. }
  9.  
  10.  
  11. public void authenticate(){
  12. param = '{"func":"auth","username":"myusername","pass":"mypassword"};
  13. somejson_contains_token = establish_connection();
  14. //parse json
  15. return token;
  16. }
  17.  
  18. public String establish_connection(){
  19. Http h = new Http();
  20. // Instantiate a new HTTP request, specify the method (GET) as well as the endpoint
  21. HttpRequest req = new HttpRequest();
  22. //String url;
  23. url +="&"+data
  24. req.setEndpoint(url);
  25. req.setMethod('GET');
  26. // Send the request, and return a response
  27. HttpResponse res = h.send(req);
  28. System.debug(url);
  29. return res.getBody();
  30. //System.debug(res.getBody());
  31. //System.debug('------------------------------------------------------');
  32. }
  33. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement