Oracle Sample Code Send SMS

 In sample code

Oracle Sample Code Send SMS

set define off;

CREATE OR REPLACE PACKAGE sms_api IS

  FUNCTION send_sms(mobiles  IN VARCHAR2,
                    message  IN VARCHAR2,
                    sender   IN VARCHAR2,
                    route    IN PLS_INTEGER,
                    country  IN PLS_INTEGER,
                    flash    IN PLS_INTEGER,
                    unicode  IN PLS_INTEGER,
                    schtime  IN VARCHAR2,
                    campaign IN VARCHAR2,
                    response IN VARCHAR2 DEFAULT 'text',
                    authkey  IN VARCHAR2 DEFAULT 'Your auth key')
    RETURN VARCHAR2;

END sms_api;
/

CREATE OR REPLACE PACKAGE BODY 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(mobiles  IN VARCHAR2,
                    message  IN VARCHAR2,
                    sender   IN VARCHAR2,
                    route    IN PLS_INTEGER,
                    country  IN PLS_INTEGER,
                    flash    IN PLS_INTEGER,
                    unicode  IN PLS_INTEGER,
                    schtime  IN VARCHAR2,
                    campaign IN VARCHAR2,
                    response IN VARCHAR2 DEFAULT 'text',
                    authkey  IN VARCHAR2 DEFAULT 'Your auth key')
    RETURN VARCHAR2 IS
    l_url    VARCHAR2(32000) := 'http://priority.muzztech.in/api/sendhttp.php';
    l_result VARCHAR2(32000);
  BEGIN
    l_url    := l_url || '?authkey=' || authkey;
    l_url    := l_url || '&mobiles=' || mobiles;
    l_url    := l_url || '&message=' || message;
    l_url    := l_url || '&sender=' || sender;
    l_url    := l_url || '&route=' || route;
    l_url    := l_url || '&country=' || country;
    l_url    := l_url || '&flash=' || flash;
    l_url    := l_url || '&unicode=' || unicode;
    IF schtime IS NOT NULL THEN
      l_url    := l_url || '&schtime=' || schtime;
    END IF;
    l_url    := l_url || '&response=' || response;
    l_url    := l_url || '&campaign=' || campaign;
    l_url := utl_url.escape(l_url);
    l_result := get_clobFromUrl(l_url);
    RETURN l_result;
  END;

END sms_api;
/
Recent Posts

Leave a Comment

Contact Us

We're not around right now. But you can send us an email and we'll get back to you, asap.

0