Php Function to send SMS via Kannel?

I used cURL and it works 100% okay. File_get_contents does not work for me because I want to pass variables to the kannel url and file_get_contents does not process variables coz it insists on using single quotes(php treats it as a string value) instead of double quotes(php will parse the string checking for variables etc). Here is what I am currently doing assuming you already have your variables initialized somewhere.

I used cURL and it works 100% okay. File_get_contents does not work for me because I want to pass variables to the kannel url and file_get_contents does not process variables coz it insists on using single quotes(php treats it as a string value) instead of double quotes(php will parse the string checking for variables etc). Here is what I am currently doing assuming you already have your variables initialized somewhere: $textmsg=""; $cellphone_number = "+254xxxxxxx" $encmsg=urlencode($textmsg); $ch= curl_init(); curl_setopt($ch, "http://localhost:13013/cgi-bin/sendsms?

Username=xxxxx&password=xxxxx&to=$cellphone_number&text=$encmsg"); curl_exec($ch); curl_close($ch); This will work for the simple task of telling kannel to send an sms to a number. Took me a while to realize curl does not recognize spaces and special characters :-).

You need to have curl installed and php running with cURL support. For linux you do sudo apt-get install php5-curl. If you check phpinfo() you should see curl somewhere.

– Max Jan 26 at 9:07.

If you're attempting to trigger a URL loading in the background (rather than by re-directing the user to the URL), you need to use something like cURL or perhaps even file_get_contents. For example, if your set up has fopen URL wrappers enabled, you could simply use: $response = file_get_contents("http://localhost:13013/cgi-bin/sendsms? Username=xxxx&password=xxxx&to=$in_number&text=$in_msg"); Irrespective, it's hard to know why the function you found won't work without some additional debug information.

(If CONFIG_KANNEL_HOST is defined as "localhost" and CONFIG_KANNEL_PORT is defined as 13013 then it's effectively doing the same thing, albeit with additional character set operations.).

That file_get_contents seems to work except that it reads the $in_number as part of the string instead of a variable. Double quotes solves the variable issue but then file_get_contents() requires a string which is defined by single quotes. Is there a way to pass the variables directly to the string?

Thanks – Max Jan 23 at 9:36 @Max file_get_contents doesn't require a string with single quotes - single and double quotes are interchangeable in PHP, as long as they're used consistently within a single construct. (The different between the two being that double quotes will evaluate any embedded variables, etc. ) As such, simply change the single quotes to double quotes and all should be well. :-) – middaparka Jan 23 at 10:18 Trust me.

They aren't interchangeable. I've tried. Trying to use cURL – Max Jan 24 at 4:29.

My friend and I from Ndola, Zambia are using ubuntu 11.04 to run kannel_1.4.3. It works perfectly way in sending and receiving sms. The code below had to be edited for it to send more that 70 characters.My friend and I struggled to figure out that there was a small error in the line '&charset=UCS-2&coding=2'.

The correct line should be '&charset=UCS-2&encoding=2'. So the code should appear as below: function sendSmsMessage($in_number, $in_msg) { $url = '/cgi-bin/sendsms? Username=' .

CONFIG_KANNEL_USER_NAME . '&password=' . CONFIG_KANNEL_PASSWORD .

'&charset=UCS-2&encoding=2' . "&to={$in_number}" .'&text=' . Urlencode(iconv('utf-8', 'ucs-2', $in_msg)).

I'm from Kenya and I use UBUNTU 10.04.3. I'll definately try this function – Max Aug 27 at 8:47.

Username=$gw_user&password=$gw_pass&to=$to&from=$shortcode&smsc=$smsc&dlr-mask=$dlrmask&binfo=$shortcode&text=$message"); Replace the various variables/parameters with your values such as: $gw_host=127.0.0.1 $gw_port=13xx3 etc.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions