Discussions
Categories
- 196.7K All Categories
- 2.2K Data
- 235 Big Data Appliance
- 1.9K Data Science
- 449.8K Databases
- 221.5K General Database Discussions
- 3.8K Java and JavaScript in the Database
- 31 Multilingual Engine
- 549 MySQL Community Space
- 477 NoSQL Database
- 7.9K Oracle Database Express Edition (XE)
- 3K ORDS, SODA & JSON in the Database
- 532 SQLcl
- 4K SQL Developer Data Modeler
- 186.8K SQL & PL/SQL
- 21.3K SQL Developer
- 295.4K Development
- 17 Developer Projects
- 138 Programming Languages
- 292.1K Development Tools
- 104 DevOps
- 3.1K QA/Testing
- 645.9K Java
- 28 Java Learning Subscription
- 37K Database Connectivity
- 153 Java Community Process
- 105 Java 25
- 22.1K Java APIs
- 138.1K Java Development Tools
- 165.3K Java EE (Java Enterprise Edition)
- 17 Java Essentials
- 158 Java 8 Questions
- 85.9K Java Programming
- 79 Java Puzzle Ball
- 65.1K New To Java
- 1.7K Training / Learning / Certification
- 13.8K Java HotSpot Virtual Machine
- 94.2K Java SE
- 13.8K Java Security
- 203 Java User Groups
- 24 JavaScript - Nashorn
- Programs
- 394 LiveLabs
- 37 Workshops
- 10.2K Software
- 6.7K Berkeley DB Family
- 3.5K JHeadstart
- 5.6K Other Languages
- 2.3K Chinese
- 170 Deutsche Oracle Community
- 1.1K Español
- 1.9K Japanese
- 230 Portuguese
PL/SQL function(s) for Mobile Verification using APEX_WEB_SERVICE

Mahmoud_Rabie
Cloud Solution Architect,Member Posts: 3,216 Bronze Crown
Hello Experts
Given:
- Nexmo SMS Service Provider used to verify mobile number. Based on documentation, just two simple steps are needed.
- Send the verify code to the number you want to verify:
curl -X POST https://api.nexmo.com/verify/json \ -d api_key=MYAPIKEY \ -d api_secret=MYAPISECRET \ -d number=MYMOBILENUMBER \ -d brand="MYBRAND"
returns
{"request_id":"MYREQUESTID","status":"0"}
- Submit the Request ID generated by step 1 and the code received via SMS to complete the verification:
curl -X POST https://api.nexmo.com/verify/check/json \ -d api_key=MYAPIKEY \ -d api_secret=MYAPISECRET \ -d request_id="REQUEST_ID" \ -d code=CODE
returns
{"request_id":"MYREQUESTID","status":"0","event_id":"anynumber","price":"0.10000000","currency":"EUR"}
Required:
Using APEX_WEB_SERVICE package, I need to write one or two PL/SQL Functions that take the mobile number and inputs and does these two POSTs and then return the result
I would appreciate any help
Regards
Mahmoud
Tagged:
Answers
-
Any help
-
Hello Mahmoud,
there is already a very similar thread about invoking nexmo api , so review it please. Assuming you have already accomplished prerequisities (ACLs+wallet/reverse proxy), you should be able to invoke the api like this:
declare --sample request (supported methods should be get and post) --https://api.nexmo.com/verify/json?api_key=xxxxxxxx&api_secret=xxxxxxxx&number=xxxxxxxxxxxx&brand=MyApp k_base_url constant varchar2(100) := 'https://api.nexmo.com/verify/json'; k_api_key constant varchar2(20) := 'my_api_key'; k_api_secret constant varchar2(20) := 'my_api_secret'; k_brand varchar2(20) := 'MyApp'; l_number varchar(20) := 'my_number'; l_url varchar2(500); l_json_response clob; l_values apex_json.t_values;begin --concatenate url or you can use p_parm_name and p_parm_value parameters l_url := k_base_url ||'?api_key=' ||k_api_key ||'&api_secret=' ||k_api_secret ||'&number=' ||l_number ||'&brand=' ||k_brand; l_json_response := apex_web_service.make_rest_request( p_url => l_url, p_http_method => 'GET' ); dbms_output.pul_line('Returned JSON: ' || l_json_response); /*output should be something like this: { "request_id":"requestId", "status":"status", "error_text":"error"} */ apex_json.parse( p_values => l_values, p_source => l_json_response ); dbms_output.put_line('request_id: ' ||apex_json.get_varchar2( p_values => l_values, p_path => 'request_id' ) ); dbms_output.put_line('status: ' ||apex_json.get_varchar2( p_values => l_values, p_path => 'status' ) ); dbms_output.put_line('error_text: ' ||apex_json.get_varchar2( p_values => l_values, p_path => 'error_text' ) ); --now you have your request id and status, so invoke the second api function analogicallyend;
Unfortunately I cannot test the code, so maybe you'll have to make some modifications/fixes.
Regards,
Pavel
This discussion has been closed.