**>Date: Tue, 8 Feb 2005 22:59:54 +0200 **>From: CosmoStation <[EMAIL PROTECTED]> **>To: users@kannel.org **>Subject: need help on SMSC hhtp **> **>Dear users/developers, **> **>I use kannel for SMS (MO/MT) using smpp connection to SMSC. **> **>I want to receive/send messages via an http api, because this is the **>only way for one carrier (they do not give any smpp access). **>But the api I am ofered is not one of these coded in smsc_http.c. I **>searched the mailing list archives for documentation and thought I **>should add a new http api. Since I am not familiarised with C, I did **>not manage to find out how this should be done. **>It seems it is too complex to me. Unfortunately, my efforts to just **>edit a few arguments to achieve what I need was not successful. **>I would appreciated it, if someone could help me on that. **> **>You can see how this http api works **> **>MO-Receiving messages: **>http://*.*.*.*/path/script?id=1&from_gsm=49171234567&to_gsm=7777&msg=hallo%20world×tamp=20050208224735 **> **>where arguments are as follows: **>id: unique SMS identifiacation **>from_gsm: from number **>to_gsm: to number **>msg: text **>timestamp: year/month/day/hour/min/sec
1) Edit gateway/gw/smsc/smsc_http.c 2) Copy the function static void kannel_receive_sms() to static void my_kannel_receive_sms(). 3) Edit the function: my_kannel_receive_sms() 3a) Define another Octstr that will be used to store the incoming value of the timestamp: Octstr *asc_timestamp; 3b) Define a variable to hold the timestamp: time_t t = (time_t) 0; 3c) Add the following before the "user = http..." line: asc_timestamp = http_cgi_variable(cgivars, "timestamp"); 3d) Comment out: user = http_cgi_variable(cgivars, "username"); 3e) Comment out: pass = http_cgi_variable(cgivars, "password"); 3f) Change from = http_cgi_variable(cgivars, "from"); to: from = http_cgi_variable(cgivars, "from_gsm"); 3g) Change to = http_cgi_variable(cgivars, "to"); to: to = http_cgi_variable(cgivars, "to_gsm"); 3h) Change text = http_cgi_variable(cgivars, "text"); to: text = http_cgi_variable(cgivars, "msg"); 3i) Change tmp_string = http_cgi_variable(cgivars, "coding"); if(tmp_string) { sscanf(octstr_get_cstr(tmp_string),"%d", &coding); } to: tmp_string = http_cgi_variable(cgivars, "Bin"); if(tmp_string) { sscanf(octstr_get_cstr(tmp_string),"%d", &coding); if (coding>1) coding=1; } 3j) Change debug("smsc.http.kannel", 0, "HTTP[%s]: Received an HTTP request", octstr_get_cstr(conn-id)); to: debug("smsc.http.my_kannel", 0, "MY_HTTP[%s]: Received an HTTP request", octstr_get_cstr(conn-id)); 3k) Search for the line: if (user == NULL || pass == NULL || Delete everything from that line until the else if (from == NULL || to == NULL || text == NULL) { Then delete the 'else' in front of the 'if' in the above line. 3l) Search for the following line within the kannel_receive_sms() function: msg->sms.time = time(NULL); Replace with: if ( octstr_len(asc_timestamp) == 14 ) { struct tm tm; char num[5]; octstr_get_many_chars(num, asc_timestamp, 0, 4); num[4] = '\0'; tm.tm_year = 1900 - atoi(num); octstr_get_many_chars(num, asc_timestamp, 4, 2); num[2] = '\0'; tm.tm_mon = atoi(num) - 1; octstr_get_many_chars(num, asc_timestamp, 6, 2); num[2] = '\0'; tm.tm_mday = atoi(num); octstr_get_many_chars(num, asc_timestamp, 8, 2); num[2] = '\0'; tm.tm_hour = atoi(num); octstr_get_many_chars(num, asc_timestamp, 10, 2); num[2] = '\0'; tm.tm_min = atoi(num); octstr_get_many_chars(num, asc_timestamp, 12, 2); num[2] = '\0'; tm.tm_sec = atoi(num); t = timelocal(&tm); } if ( t != (time_t)0 ) { msg->sms.time = t; } msg->sms.time = time(NULL); } **>For Sending messages I must use an HTTP GET: **>http://*.*.*.*/path/send.html?from_gsm=7777&to_gsm=234567&Bin=0&msg=hallo%20again **> **>almost same as above, but: **>to_gsm without country/carrier code **>Bin: 0:text message, 1:binary data (actually I never send any binary SMS) **> **>Users authenticate on a "IP" and "from_gsm" combination. **> 4) Copy the function static void kannel_send_sms() to static void my_kannel_send_sms(). 5) Edit the function: static void my_kannel_send_sms() 5a) Change url = octstr_format("%S?" "username=%E&password=%E&to=%E&text=%E", conndata->send_url, conndata->username, conndata->password, sms->sms.receiver, sms->sms.msgdata); to: url = octstr_format("%S?" "&to_gsm=%E&msg=%E", conndata->send_url, sms->sms.receiver, sms->sms.msgdata); In the if as well as the else clauses. 5b) Change if (!conndata->no_sender) octstr_format_append(url, "&from=%E", sms->sms.sender); to: if (!conndata->no_sender) octstr_format_append(url, "&from_gsm=%E", sms->sms.sender); 5c) Change if (!conndata->no_coding && sms->sms.coding != DC_UNDEF) octstr_format_append(url, "&coding=%d", sms->sms.coding); to: if (!conndata->no_coding && sms->sms.coding != DC_UNDEF) octstr_format_append(url, "&Bin=%d", (sms->sms.coding==0)?0:1); 5d) Change debug("smsc.http.kannel", 0, "HTTP[%s]: Start request", octstr_get_cstr(conn->id)); to: debug("smsc.http.my_kannel", 0, "MY_HTTP[%s]: Start request", octstr_get_cstr(conn->id)); 6) Copy the function static void kannel_parse_reply() to static void my_kannel_parse_reply(). 7) Edit the function: static void my_kannel_parse_reply() 7a) Change the expected string located in the body of an HTTP_OK response (i.e HTTP 200 response) or HTTP_ACCEPTED (i.e HTTP 202). 8) Edit function smsc_http_create(). 8a) Change if (octstr_case_compare(type, octstr_imm("kannel")) == 0) { to: if (octstr_case_compare(type, octstr_imm("my_kannel")) == 0) { conndata->receive_sms = my_kannel_receive_sms; conndata->send_sms = my_kannel_send_sms; conndata->parse_reply = my_kannel_parse_reply; } else if (octstr_case_compare(type, octstr_imm("kannel")) == 0) { 9) In your Kannel config file for the bearerbox have the following: # HTTP SMSC. # 1) MO SMS will connect to bearerbox port based on "port = ...." # Base URL for MO SMS is irrelevant because bearerbox will look for # CGIVARs instead of the base of the URL. # 2) MT SMS must specify "myhttp_smsc" as the smsc-id. send-url contains # the Base URL for sending an MT SMS to the remote HTTP SMSC. # 3) smsc-username and smsc-password are not used but must to be filled # because of a check in gateway/gw/smsc/smsc_http.c:smsc_http_create(). # group = smsc smsc = http smsc-id = "myhttp_smsc" system-type = my_kannel port = .... smsc-username = "ignored" smsc-password = "ignored" no-sender = false no-coding = false send-url = "http://*.*.*.*/path/send.html" That should do it. I've given a standard framework for you to use. You should be able to tweak it so that it works properly with the proprietary HTTP SMSC. See ya... d.c.