likai wrote:

Hi,

I read in the news group , knowing you had added a new HTTP smsc quite successfully. Sorry for not able to help

you but I do really need your help as I am also want to add a new HTTP smsc in the Kannel system.

The SMSC need me to send and get request “request header”.

How would I modify the smsc_http.c so I can change the format of the URL to pass to the new HTTP smsc centre together with The “request header” information ?

Hi likai,
at first, you must figure out, which parameters your smsc expect and how they were called.
Mostly, you have to deliver your username, password, the receiver number, the sms text and optionaly the sender number
for example. kannel supports all these Parameters. In my case, I only had to change the names of the parameters.
Here an example :
Kannels sms text parameter name : "text"
My smsc's sms text parameter name : "message"


Now we take smsc_http.c and look at line 198 (kannel 1.2.1) :
Here we find the explaination about three functions, which specify a http service type:


/*----------------------------------------------------------------
* SMSC-type specific functions
*
* 3 functions are needed for each:
*
* 1) send SMS
* 2) parse send SMS result
* 3) receive SMS (and send reply)
*
* These functions do not return anything and do not destroy
* arguments. They must handle everything that happens therein
* and must call appropriate bb_smscconn functions
*/

/*xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

After this, the three functions for kannel hhtp service type follows.
To build your own http service type, you can copy these three functions and
paste them at the bottom of the kannel http functions.
Remember to change their names . (Kannel_send_sms --> YourSMSC_send_sms)
Now modifiy the new functions , so that they fit to your smsc.
(If you need an example, tell me)
The last thing to do, is to point kannel to the new functions, if it sees the new service type:
[qoute]
int smsc_http_create(SMSCConn *conn, CfgGroup *cfg)
[/quote]
at the end of the file, is right place to do this.
within this function you will find something like that :
[quote]
if (octstr_case_compare(type, octstr_imm("kannel"))==0) {
if (conndata->username == NULL || conndata->password == NULL) {
error(0, "username and password required for Kannel http smsc");
goto error;
}
conndata->receive_sms = kannel_receive_sms;
conndata->send_sms = kannel_send_sms;
conndata->parse_reply = kannel_parse_reply;
}
[/quote]


This query checks your smsc type and points to the proper functions.
Copy it and paste it directly behind.
Change it to your requirement.
[quote]
if (octstr_case_compare(type, octstr_imm("YourSMSC"))==0) {
if (conndata->username == NULL || conndata->password == NULL) {
error(0, "username and password required for YOURSMSC http smsc");
goto error;
}
conndata->receive_sms = YourSMSC_receive_sms;
conndata->send_sms = YourSMSC_send_sms;
conndata->parse_reply = YourSMSC_parse_reply;
}
[/quote]

That's it.

P.S.: Don't wory about the http header, kannel does automatically send the right one.

regards Jeremias

Regards,

Ray





Reply via email to