SMS service in Oracle Database & APEX

Oracle Application Express is a rapid development tool for Web applications on the Oracle database.
Post Reply
admin
Posts: 1999
Joined: Fri Mar 31, 2006 12:59 am
Location: Pakistan
Contact:

SMS service in Oracle Database & APEX

Post by admin »

In Pakistan, if you want to use SMS service then try to get a package from a company like http://lifetimesms.com or any other company providing such services and integrate as below in the Oracle database. by Muhammad Abrar


CREATE OR REPLACE PACKAGE erpstuff_sms_api IS

FUNCTION send_sms(api_token IN VARCHAR2 DEFAULT 'd49b82b15',
api_secret IN VARCHAR2 DEFAULT 'cmd',
tto IN VARCHAR2 DEFAULT '923007736',
ffrom IN VARCHAR2,
message IN VARCHAR2)
RETURN VARCHAR2;

END erpstuff_sms_api;
/

CREATE OR REPLACE PACKAGE BODY erpstuff_sms_api IS

FUNCTION get_clobFromUrl(p_url VARCHAR2) RETURN CLOB IS
req utl_http.req;
resp utl_http.resp;
val VARCHAR2(32767);
l_result CLOB;
BEGIN
req := utl_http.begin_request(p_url);
resp := utl_http.get_response(req);
LOOP
utl_http.read_line(resp, val, TRUE);
l_result := l_result || val;
END LOOP;
utl_http.end_response(resp);
RETURN l_result;
EXCEPTION
WHEN utl_http.end_of_body THEN
utl_http.end_response(resp);
RETURN l_result;
WHEN OTHERS THEN
utl_http.end_response(resp);
RAISE;
END;

FUNCTION send_sms(api_token IN VARCHAR2 DEFAULT 'd4c2b15',
api_secret IN VARCHAR2 DEFAULT 'cmd_cmd',
tto IN VARCHAR2 DEFAULT '123',
ffrom IN VARCHAR2,
message IN VARCHAR2)
RETURN VARCHAR2 IS
l_url VARCHAR2(32000) := 'http://lifetimesms.com/json';
l_result VARCHAR2(32000);
BEGIN
l_url := l_url || '?api_token=' || api_token;
l_url := l_url || '&api_secret=' || api_secret;
l_url := l_url || '&to=' || tto;
l_url := l_url || '&from=' || ffrom;
l_url := l_url || '&message=' || message;
l_url := utl_url.escape(l_url);
l_result := get_clobFromUrl(l_url);
RETURN l_result;
END;

END erpstuff_sms_api;
/

--------------------------------------------------------------------
--Run:
--SELECT erpstuff_sms_api.send_sms("api_token","api_secret","to","from","message") FROM dual;

--Example :
SELECT erpstuff_sms_api.send_sms('d49c2b15','cmd_cmd','300744736','SmartSMS','This is Test Message') FROM dual;
Post Reply

Who is online

Users browsing this forum: No registered users and 0 guests