使用smsj:发送Base64编码字符串的SMS

时间:2015-02-20 12:28:45

标签: java html sms-gateway

我有一个Base64编码的Java String。我需要通过短信将Java String发送到GSM移动电话上的另一个SMS应用程序,该移动电话期望String以Basse64编码格式传送。我正在使用带有smsj java库的Clickatell HTTP API,如下所示:

public void SendBinarySMSMessage(String toPhone, String cTxt, String toPort, String fromPhone) throws Exception {
// Note that 'cTxt' is Base64 encoded string 
    Properties props = new Properties();
    props.setProperty("smsj.clickatell.username", "xxxxxxx");
    props.setProperty("smsj.clickatell.password","yyyyy");
    props.setProperty("smsj.clickatell.apiid","zzzzzzz");
    // Now load the clickatell transport
    SmsTransport transport = SmsTransportManager.getTransport("org.marre.sms.transport.clickatell.ClickatellTransport", props);
    // Connect to clickatell
    transport.connect();
    // Create and send the sms message
    int dstPort = Integer.parseInt(toPort);
    int srcPort = Integer.parseInt(toPort);
    SmsPortAddressedTextMessage textMessage = new SmsPortAddressedTextMessage(dstPort,srcPort,cTxt);
    transport.send(textMessage,new SmsAddress(toPhone),new SmsAddress(fromPhone));
    // Disconnect from clickatell
    transport.disconnect();
}

每次我尝试发送消息时,都会出现以下错误:

SEVERE:   org.marre.sms.SmsException: Clickatell API cannot send 7 bit encoded messages with UDH
at org.marre.sms.transport.clickatell.ClickatellTransport.buildSendRequest(ClickatellTransport.java:385)

以下是我尝试发送的cTXT字符串的值:“56pRfQSuddMbjOc8ibMyYKkmLTQ8AZpAz3sT + 5JrGDw =”

如何解决此问题?

谢谢。

0 个答案:

没有答案