kalkun-sms/Kalkun

Unable to send Unicode messages via REST API

Closed this issue · 5 comments

Hello. Good day.
Using the code from the devel branch, I'm able to activate and use the REST API successfully.
The issue I'm facing is related to sending Unicode messages via the the REST API. Although the API accepts the messages correctly, they are delivered to the destination with most of the special characters stripped out.
If I sent the same message via the Web interface, ticking the Unicode checkbox, the message is delivered correctly.
Comparing the DB records from a message sent via Web Interface versus a message sent via REST API, I find that the "Coding" field on the "sentitems" table is different.
Messages generated from the Web interface have the "Coding" as "Unicode_No_Compression" (assuming Unicode checkbox is ticket on the interface).
Messages generated via REST API have the "Coding" as "Default_No_Compression".
This is suggesting me that some is flag via the Web interface and not flagged via REST API.
Is there any way to flag messages from REST API to be marked and processed as Unicode?
Thank you.

I found a possible culprit!
On line #40 of /application/plugins/rest_api/controllers/Rest_api.php, there a mention for the coding element:
$data['coding'] = 'default';
Changing that to:
$data['coding'] = 'unicode';
does the trick, the Unicode messages sent via REST API are correctly delivered.
As suggestion, ideally, this should be a flag where user can choose the type of message they want to send via a URL parameter...
I'll wait for one of the Devs here to weight in.
Thank you.

Thanks for finding out.
Can you test all cases with commit tenzap@801b232 ? If it's ok, I will submit a PR.

rest API: add possibility to set coding in the URL
If parameter is not set in the URL it will set "default"
Otherwise it will set the value for "coding"
To set coding to unicode, URL should contain
...&coding=unicode

Great.
I'm having some issues with GitHub, I'll test and report here as soon as I was able to solve them.
Thanks again.

use rather this
tenzap@801b232

Yep. Tested and works fine with informed commit.
Closing this issue.
Thank you.