Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- global class IpdReqDev {
- String url;
- String data;
- String token{get;set;}
- Public String mytext {get;set;}
- public IpdReqDev() {
- url = 'some landing api url/index.php?action=api';
- }
- public void authenticate(){
- param = '{"func":"auth","username":"myusername","pass":"mypassword"};
- somejson_contains_token = establish_connection();
- //parse json
- return token;
- }
- public String establish_connection(){
- Http h = new Http();
- // Instantiate a new HTTP request, specify the method (GET) as well as the endpoint
- HttpRequest req = new HttpRequest();
- //String url;
- url +="&"+data
- req.setEndpoint(url);
- req.setMethod('GET');
- // Send the request, and return a response
- HttpResponse res = h.send(req);
- System.debug(url);
- return res.getBody();
- //System.debug(res.getBody());
- //System.debug('------------------------------------------------------');
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement