Advertisement
Guest User

Untitled

a guest
Oct 14th, 2016
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.62 KB | None | 0 0
  1. <apex:page controller="HeddyLoginController">
  2. <apex:form>
  3. <apex:pageBlock title="Login to Heddy">
  4. <apex:pageMessages/>
  5. <apex:pageBlockButtons>
  6. <apex:commandButton value="Search" action="{!login}"/>
  7. </apex:pageBlockButtons>
  8. <apex:pageBlockSection>
  9. <apex:inputfield label="Heddy username" value="{!ps.HeddyUsername__c}"/>
  10. </apex:pageBlockSection>
  11. <apex:pageBlockSection>
  12. <apex:inputSecret label="Heddy password" value="{!ps.HeddyPassword__c}"/>
  13. </apex:pageBlockSection>
  14. </apex:pageBlock>
  15. </apex:form>
  16. </apex:page>
  17.  
  18. public class HeddyLoginController {
  19.  
  20. public String baseEndpoint = 'https://api.Heddy.com/lkapi/';
  21. public HeddySession__c ps { get; set; }
  22.  
  23.  
  24. public void HeddyLoginController() {
  25. ps = [SELECT APIAuthorizationKey__c from HeddySession__c LIMIT 1];
  26.  
  27. if (ps == null) {
  28. ps = new HeddySession__c();
  29. try {
  30. insert ps;
  31. } catch(System.DMLException e) {
  32. ApexPages.addMessages(e);
  33. ApexPages.Message msgErr = new ApexPages.Message(ApexPages.Severity.ERROR, 'Error! We are unable to save your session in Salesforce.');
  34. ApexPages.addmessage(msgErr);
  35. }
  36. }
  37. }
  38.  
  39. public HttpResponse fetch() {
  40. Http httpProtocol = new Http();
  41. HttpRequest request = new HttpRequest();
  42. HttpResponse response;
  43.  
  44. String authpoint = '/authtoken?user=' + ps.HeddyUsername__c + '&pass=' + ps.HeddyPassword__c;
  45.  
  46. Attempt to de-reference a null object
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement