SALESFORCE INTEGRATION FROM 46ELKS USING REST API

Salesforce Integration with 46elks using Rest Api :

Hi Guys, Today i will share the new integration with salesforce.  Basically 46elks provide the service for phone call and send message. That is so simple. for  this you have to create the trail account on 46elks. after creating account on 46elks you will get you api credential  for using the service.
So, Here we go.......

Here i am sharing some code snippet for that : 

Visualforce Page:

<apex:page controller="SalesforceElk" tabStyle="Account">
    <apex:form id="frm">
        <apex:outputText value="{!error}" style="color:green;font-weight:50px"/> 
        <apex:pageBlock title="Call From Elk">
            <apex:pageBlockSection collapsible="false" columns="2" title="Call Information">
                <apex:inputText value="{!callnumber}"/>
                <apex:commandButton value="Call" action="{!callElk}" reRender="frm"/>
            </apex:pageBlockSection>
        </apex:pageBlock>
    </apex:form>  
</apex:page>


Apex Controller:


public class SalesforceElk{
    public String callnumber{get;set;}
    public String error{get;set;}
    public SalesforceElk(){}
    
    public void callElk() {
        String auth_user = 'Your api username ';
        String auth_pass = 'Your api password';
        
        HttpRequest req = new HttpRequest();
        
       
        
        req.setHeader('Authorization', 'Basic '+ EncodingUtil.base64Encode(Blob.valueOf(auth_user + ':' +auth_pass )));
      
        req.setHeader('Content-Type','application/x-www-form-urlencoded');
        req.setEndpoint('https://api.46elks.com/a1/Calls');
        req.setMethod('POST');
         req.setBody(''
               + 'from=' + EncodingUtil.urlEncode('+919784*******', 'UTF-8')
               + '&to=' + EncodingUtil.urlEncode('+919784******', 'UTF-8')
               + '&voice_start=' + EncodingUtil.urlEncode('http://yourdomain-developer-edition.ap5.force.com/newCall', 'UTF-8'));
        HttpResponse res = new Http().send(req);
        if (res.getStatusCode() >= 200 && res.getStatusCode() < 300) {
                 error = 'Message Send Successfully....!!';
                 String response = res.getBody();
        }
        else{
            String response = res.getBody();
            error = 'Call Could not be completed'+response;
        }
   }
}





Note:

- In trail account of 46elks we could only call on our registered mobile number.
- you could get your credentials on the your account dashboard 
  Api Username and Api Password


Comments

Popular posts from this blog

PATH IS NOT COMING IN MOBILE??

WHATSAPP INTEGRATION WITH SALESFORCE

UPLOAD FILE FROM JAVASCRIPT REMOTING