Send/receive sms with php

Send/receive sms with php SearchSearch
Author Message
beppe
New member
Username: Grogno

Post Number: 2
Registered: 05-2011
Posted on Monday, June 06, 2011 - 09:00 am:   

Hi, When I send or receive a sms with sendsms.php characters à, è, ì, ò, ù are not sent / received. Any suggestions?
Des - NowSMS Support
Board Administrator
Username: Desosms

Post Number: 3230
Registered: 08-2008
Posted on Monday, June 06, 2011 - 03:30 pm:   

Hi beppe,

Do these characters send ok when you send via the NowSMS web interface?

Assuming that they are ok that way ...

This is a character set issue. NowSMS assumes that text messages submitted via HTTP (and this PHP script) will be encoded using the UTF-8 character set.

For sending messages, you need to either convert to UTF-8 (see PHP functions utf8_encode and mb_convert_encoding) ... or you can tell NowSMS what character set you are using when you submit a message.

I'm guessing that you are using the iso-8859-1 character set (US/Western Europe). In this case, "&charset=iso-8859-1" needs to be appended to the HTTP URL when submitting a message. There is an updated version of sendsms.php in the following article:

http://www.nowsms.com/send-sms-from-php-script-updated

The updated sendsms.php is very similar to the first one, but it allows additional NowSMS URL parameters to be added, such as the following example which adds a parameter to indicate what character set is used for the text encoding:

$x = SendSMS("127.0.0.1", 8800, "username", "password", "+44999999999", "Test Message", "charset=iso-8859-1");

For the receiving side, the character set that is used for sending text to the 2-way commands is configured on the "2-way" configuration page. Again, by default UTF-8 is used so that all languages are supported by default, but this can be changed to use a different character set such as iso-8859-1.

--
Des
NowSMS Support