twilio / twilio-salesforce

A Salesforce/Force.com library for communicating with the Twilio REST API and generating TwiML. Need help? Post your questions to http://getsatisfaction.com/twilio or email us at help@twilio.com
http://www.twilio.com/salesforce
MIT License
189 stars 136 forks source link

Script-thrown Exception in TwilioSMS class #59

Open utkarshugale opened 8 years ago

utkarshugale commented 8 years ago
       Hi,

       Following is piece of my code. When this code is executed, I am getting Script-thrown exception. Any idea what could be wrong config/code here ? I am setting correct 'accountId' & 'authToken' value.

       private static TwilioSMS twilioSms;
       //Creating Twilio Client
        TwilioRestClient client = new TwilioRestClient(accountId, authToken);

        //Adding parameters to send in SMS
        Map<String,String> params = new Map<String,String>();
        params.put('To',phoneNumber);
        params.put('From',fromPhone);
        params.put('Body',textMessage);
        try{
            twilioSms = null;
            twilioSms = client.getAccount().getSMSMessages().create(params);
            System.debug(LoggingLevel.Error,'SMS Sent '+twilioSms);
        }catch(Exception e){
            String exceptionMessage = 'Exception Message: ' + e.getMessage();
            exceptionMessage += '\nTwilio Client Info: ' + client;
            exceptionMessage += '\nTwilio Params Passed: ' + params;
            System.debug(LoggingLevel.ERROR,'Error: '+ exceptionMessage);
            throw new SmsException(exceptionMessage);
        }