我希望在Salesforce
中为AppExchange创建一个应用
目的是登录到我的PBX并启用click_and_dial
其实我有这段代码:
<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;
}
}
我需要用户登录令牌才能调用API
如何存储用户的PBX凭据,然后从clickAndDial
方法中检索它们,以便在PBX上执行登录?