Sending arabic SMS in kannel

给你一囗甜甜゛ 提交于 2019-12-01 08:37:57

i have been able to send arabic/french sms with this http request example :

StringBuffer param = new StringBuffer()
       param.append("http://localhost:1025/cgi-bin/sendsms?")
       param.append(URLEncoder.encode("username","UTF-8")).append("=").append(URLEncoder.encode("xxx","UTF-8"))
       param.append("&").append(URLEncoder.encode("password","UTF-8")).append("=").append(URLEncoder.encode("xxxx","UTF-8"))
       param.append("&").append(URLEncoder.encode("to","UTF-8")).append("=").append(URLEncoder.encode(numTel,"UTF-8"));

       param.append("&").append(URLEncoder.encode("coding","UTF-8")).append("=").append(URLEncoder.encode("2","UTF-8"))
       param.append("&").append(URLEncoder.encode("text","UTF-8")).append("=").append(URLEncoder.encode(text,"UTF-8"))
       param.append("&").append(URLEncoder.encode("priority","UTF-8")).append("=").append(URLEncoder.encode(""+priority,"UTF-8"))
       param.append("&").append(URLEncoder.encode("dlr-mask","UTF-8")).append("=").append(URLEncoder.encode("31","UTF-8"))
       param.append("&").append(URLEncoder.encode("dlr-url","UTF-8")).append("=").append(URLEncoder.encode(urlString,"UTF-8"))
       try{
           URL url = new URL(param.toString())
           System.out.println("INFO : Opening connection ")
           HttpURLConnection urlconnection = (HttpURLConnection) url.openConnection()
           System.out.println("INFO : Connection openned")
           BufferedReader input = new BufferedReader( new InputStreamReader(urlconnection.getInputStream()))
           String inputLine

           while ((inputLine = input.readLine()) != null)
               aResult.append(inputLine)
           input.close()
       }catch(Exception e){
           e.printStackTrace()
           return false
       }

       System.out.println("response : "+aResult.toString())
       System.out.println("INFO : all sent disconnect.")

i don't send the "charset" parameter in my request i only send the coding parameter

I've made a bit of research, and I believe that if you specify coding=2 Kannel expects the message body encoded as UTF-16, at least if I understood correctly this discussion.
Also you should have a look at this document.

All you have to do is the following (kannel release 1.5): 1- Add alt-charset="UTF-8" under smsc group in your kannel configuration 2- when sending the sms مرحبا for example you have to type type the following in your sendsms command: text=مرحبا&charset=UTF-8&coding=1

Check your database using mysql command because database management tools like webmin may not recognize Arabic letters

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!