Skip to content

Instantly share code, notes, and snippets.

@dhaniksahni
Created October 2, 2019 13:15
Show Gist options
  • Save dhaniksahni/8800e7f1f057958c0dc7d7c2b1c3d75a to your computer and use it in GitHub Desktop.
Save dhaniksahni/8800e7f1f057958c0dc7d7c2b1c3d75a to your computer and use it in GitHub Desktop.
public class StackExchangeAccess {
@AuraEnabled
public static StackExchangeUserWrapper getUsers(integer pageNumber,integer pageSize,string sortdirection, string sortName, string sitename)
{
string url='page='+pageNumber+'&pagesize='+ pageSize+'&order='+sortdirection+'&sort='+sortName+'&site='+sitename;
Http http = new Http();
HttpRequest request = new HttpRequest();
request.setEndpoint('https://api.stackexchange.com/2.2/users?'+url);
request.setMethod('GET');
HttpResponse response = http.send(request);
if (response.getStatusCode() == 200) {
StackExchangeUserWrapper wrapper=StackExchangeUserWrapper.parse(response.getBody());
return wrapper;
}
return null;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment