I am looking to create an app for AppExchange in Salesforce
The goal is to login to my PBX and enable click_and_dial
Actually I have this code:
<apex:page standardController="Contact" extensions="ClickAndDial" action="{!clickAndDial}">
<apex:form >
<apex:inputHidden value="{!contact.Id}"/>
<apex:inputHidden value="{!contact.Phone}"/>
</apex:form>
</apex:page>`
public class ClickAndDial {
public String Phone {get; set;}
public Id Id { get; set; }
public Contact contact { get; set; }
public ClickAndDial(ApexPages.StandardController controller) {
contact = (Contact) controller.getRecord();
Id = contact.Id;
System.debug('The case record: ' + contact);
Phone = contact.Phone;
}
....
public PageReference clickAndDial() {
PageReference pageRef = new PageReference('/' + Id);
HTTPRequest loginRequest = new HTTPRequest();
loginRequest.setEndpoint('callout:SalesforceNC/services/data/v32.0');
System.debug('Case Owner: ' + Phone);
System.debug('Case Id: ' + Id);
Http http = new Http();
HttpRequest request = new HttpRequest();
request.setMethod('POST');`
request.setEndpoint('https://somendpoint');
request.setHeader('Content-Type', 'application/x-www-form-urlencoded');
String payload = 'token=' + EncodingUtil.urlEncode('pbx_login_token','UTF-8') + '&data='+EncodingUtil.urlEncode('my_data','UTF-8');
request.setBody(payload);
HttpResponse response = http.send(request);
return pageRef;
}
}
I need user login token to be able to call API
How can I store user's PBX credentials and then retrieve them from clickAndDial
method in order to perform login on PBX?