Skip to content

Instantly share code, notes, and snippets.

@arun12209
Created December 28, 2019 16:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save arun12209/78f625de40426b58809b62b25857a2fc to your computer and use it in GitHub Desktop.
Save arun12209/78f625de40426b58809b62b25857a2fc to your computer and use it in GitHub Desktop.
FullContactAccountDetailsContrl
public class FullContactAccountDetailsContrl {
@AuraEnabled
public static string getAccountDetails(string rec_id){
String msg = '';
try{
Account acc=[select Website from account where id=:rec_id ];
system.debug('domain : '+ acc.Website);
if(acc.Website != null && acc.Website != ''){
string baseURL = 'https://api.fullcontact.com/v2/company/lookup.json?domain';
string apikey = '9e340d31aXXXXXXX'; // Your API Key (Register on https://dashboard.fullcontact.com/register to get API Key)
string url = baseURL +'='+ acc.Website + '&apiKey=' + apikey;
HttpRequest req = new HttpRequest();
Http http = new Http();
req.setMethod('GET');
req.setEndpoint(url);
HttpResponse res = http.send(req);
system.debug('response status code: '+res.getStatusCode());
system.debug(''+res.getBody());
string body=res.getBody();
system.debug('Retured Body: '+body);
if (res.getStatusCode() == 200) {
return res.getBody();
}
else{
return null;
}
}
else{
return 'Enter website to see the company profile';
}
}
catch(Exception e){
return null;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment