{"id":37,"date":"2020-02-14T09:19:53","date_gmt":"2020-02-14T09:19:53","guid":{"rendered":"https:\/\/www.osdigital.in\/blog\/?p=37"},"modified":"2020-02-26T08:38:41","modified_gmt":"2020-02-26T08:38:41","slug":"what-is-http-api-in-bulk-sms-and-sample-api-codes-in-different-languages","status":"publish","type":"post","link":"https:\/\/www.osdigital.in\/blog\/what-is-http-api-in-bulk-sms-and-sample-api-codes-in-different-languages\/","title":{"rendered":"What is HTTP API in Bulk SMS and Sample API Codes in different languages?"},"content":{"rendered":"<div style=\"margin-top: 0px; margin-bottom: 0px;\" class=\"sharethis-inline-share-buttons\" ><\/div>\n<p> Bulk SMS API is a string, plays an important role to integrate any application to messaging platform. It secure your data and protects your application or software to access with proper mobile authentication. Mobile number authenticated through the OTP (One Time Password) verification. This is the example of HTTP String :<\/p>\n\n\n\n<p><a href=\"https:\/\/bulksmsindia.app\/V2\/http-api.php?apikey=xxxxxxxxxxxxxxxxx&amp;senderid=xxxxxx&amp;number=xxxxxxxxxx,xxxxxxxxxxX&amp;message=hello\">https:\/\/bulksmsindia.app\/V2\/http-api.php?apikey=xxxxxxxxxxxxxxxxx&amp;senderid=xxxxxx&amp;number=xxxxxxxxxx,xxxxxxxxxxX&amp;message=hello<\/a><\/p>\n\n\n\n<p>This API is showing different parameters, like apikey, sender id, number and message. These are variable and need to enter the variables while sending SMS. This is a highly secure and easy to integrate into any application. Here we have given different use cases of the Bulk SMS API.<br>1. Two factor authentication.<br>2. OTP(One Time Password) Login.<br>3. Mobile Number Verification.<br>4. Opt-in Subscription.<br>5. Retrieve Password.<br>6. Registration confirmation and many more. <\/p>\n\n\n\n<p> We would like to introduce different types of <a href=\"http:\/\/www.osdigital.in\/api.html\"><strong>Bulk SMS API<\/strong><\/a> to be configured according to the requirement of applications as the different applications are developed in different playtform. These APIs helps you to integrate your application according to requirement. <strong><a href=\"http:\/\/www.osdigital.in\/transactional-sms.html\">SMS Service provider<\/a><\/strong> or vendor provides SMS API according to customers requirement, below are the sample codes for different languages : <\/p>\n\n\n\n<p><strong>*******SAMPLE CODE : PHP*******<\/strong><\/p>\n\n\n\n<p>$sender =&#8217;XXXX&#8217;;<br>$mob =&#8217;XXXXX&#8217;;<br>$auth=&#8217;Your auth key&#8217;;<br>$msg = urlencode(&#8220;test&#8221;);<\/p>\n\n\n\n<p>$url = <a href=\"https:\/\/bulksmsindia.app\/V2\/http-api.php?apikey='.$auth.'&amp;senderid='.$sender.'&amp;number='.$mob.'&amp;message='.$msg.'&quot;;\">&#8216;http:\/\/202.143.96.204\/API\/sms-api.php?auth=&#8217;.$auth.&#8217;&amp;msisdn=&#8217;.$mob.&#8217;&amp;senderid=&#8217;.$sender.&#8217;&amp;message=&#8217;.$msg.&#8217;;<\/a> &nbsp;\/\/ API URL<\/p>\n\n\n\n<p>$result=SendSMS($url); &nbsp;\/\/ call function that return response with code<br>echo $result;<\/p>\n\n\n\n<p>\/\/function define<br>function SendSMS($hostUrl){<br>$ch = curl_init();<br>curl_setopt($ch, CURLOPT_URL, $hostUrl);<br>curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);<br>curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);<br>curl_setopt($ch, CURLOPT_POST, 0);<br>curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0); \/\/ change to 1 to verify cert<br>curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_ANY);<br>\/\/curl_setopt($ch, CURLOPT_USERPWD, &#8220;$username:$password&#8221;);<br>$result = curl_exec($ch);<br>return $result;<br>}<\/p>\n\n\n\n<p><strong>*******SAMPLE CODE :&nbsp;<a href=\"http:\/\/asp.net\/\" target=\"_blank\" rel=\"noreferrer noopener\">ASP.NET<\/a>*******<\/strong><\/p>\n\n\n\n<p>using System;<br>using System.Data;<br>using System.Configuration;<br>using System.Collections;<br>using System.Web;<\/p>\n\n\n\n<p>using System.IO;<br>using System.Net;<\/p>\n\n\n\n<p>public void SMSSend()<br>{<br>WebClient client = new WebClient();<br>string baseurl = &#8220;<a href=\"https:\/\/bulksmsindia.app\/V2\/http-api.php?apikey=xxxxxxxxxxxxxxxxxxxx&amp;senderid=xxxxxx&amp;number=xxxxxxxxxx&amp;message=hello\" target=\"_blank\" rel=\"noreferrer noopener\">https:\/\/bulksmsindia.app\/V2\/http-api.php?apikey=xxxxxxxxxxxxxxxxxxxx&amp;senderid=xxxxxx&amp;number=xxxxxxxxxx&amp;message=hello<\/a>&#8220;;<br>Stream data = client.OpenRead(baseurl);<br>StreamReader reader = new StreamReader(data);<br>string s = reader.ReadToEnd();<br>data.Close();<br>reader.Close();<br>}<\/p>\n\n\n\n<p><strong>*******SAMPLE CODE : ASP******* &nbsp; &nbsp; &nbsp; &nbsp;<\/strong><\/p>\n\n\n\n<p>sResponse = SMSSend(pno, message )<br>If right(sResponse,15) = &#8220;Send Successful&#8221; Then<br>&#8216;write your code here<br>End If<\/p>\n\n\n\n<p>Function SMSSend (strPh,strMsg)<\/p>\n\n\n\n<p>Dim msgResponse<br>Dim strRequest<br>Dim strUrl<br>msgResponse = &#8220;&#8221;<\/p>\n\n\n\n<p>strPh=right(strPh,10)<br>If not IsNumeric(strPh) Or len(strPh) &lt;&gt; 10 Then<br>msgResponse = &#8220;Enter valid Mobile Number.&#8221;<br>End If<br>If strMsg = &#8220;&#8221; Then<br>msgResponse = &#8220;Enter text message.&#8221;<br>End If<\/p>\n\n\n\n<p>strUrl = &#8220;<a href=\"https:\/\/bulksmsindia.app\/V2\/http-api.php\" target=\"_blank\" rel=\"noreferrer noopener\">https:\/\/bulksmsindia.app\/V2\/http-api.php<\/a>?&#8221;<br>strRequest = strRequest+&#8221;apikey=xxxxxxxxxxxxxxxxxxxx&#8221;<br>strRequest = strRequest+&#8221;&amp;senderid=sender&#8221;<br>strRequest = strRequest+&#8221;&amp;number=&#8221;+strPh<br>strRequest = strRequest+&#8221;&amp;message=&#8221;+Server.URLEncode(strMsg)<\/p>\n\n\n\n<p>strUrl = strUrl+strRequest<\/p>\n\n\n\n<p>If msgResponse = &#8220;&#8221; Then<br>Dim oXML<br>Dim sPage<br>Err.Clear<br>On Error Resume Next<br>Set oXML = Server.CreateObject(&#8220;Msxml2.XMLHTTP&#8221;)<br>oXML.Open &#8220;get&#8221;, strUrl , false<br>oXML.Send<br>msgResponse = oXML.ResponseText<br>Set oXML = Nothing<br>End If<\/p>\n\n\n\n<p>SMSSend = msgResponse<\/p>\n\n\n\n<p>If Err.Number &lt;&gt; 0 Then<br>SMSSend = &#8220;Problem on sending sms : &#8220;&amp; Err.Description<br>End If<\/p>\n\n\n\n<p>End Function<\/p>\n\n\n\n<p><strong>*******SAMPLE CODE : PYTHON*******<\/strong><\/p>\n\n\n\n<p>import http.client<br>conn = http.client.HTTPSConnection(&#8220;bulksmsindia.app&#8221;)<br>headers = {<br>&#8216;cache-control&#8217;: &#8220;no-cache&#8221;<br>}<br>conn.request(&#8220;GET&#8221;, &#8220;\/V2\/http-api.php?apikey=xxxxxxxxxxxxxxxxxxxx&amp;senderid=xxxxxx&amp;number=xxxxxxxxxx&amp;message=hello&#8221;, headers=headers)<br>res = conn.getresponse()<br>data = res.read()<br>print(data.decode(&#8220;utf-8&#8221;))<\/p>\n\n\n\n<p><strong>*******SAMPLE CODE : NODE JS*******<\/strong><\/p>\n\n\n\n<p>var request = require (&#8220;request&#8221;);<br>var options = { method: &#8216;GET&#8217;,<br>&nbsp; url: &#8216;<a href=\"https:\/\/bulksmsindia.app\/V2\/http-api.php?\" target=\"_blank\" rel=\"noreferrer noopener\">https:\/\/bulksmsindia.app\/V2\/http-api.php?<\/a>&#8216;,<br>&nbsp; qs:<br>&nbsp; &nbsp;{<br>apikey: &#8216;xxxxxxxxxxxxxxxxxxxx&#8217;,<br>&nbsp; &nbsp; senderid: &#8216;xxxxxx&#8217;,<br>&nbsp; &nbsp; number: &#8216;xxxxxxxxxx&#8217;,<br>&nbsp; &nbsp; message: &#8216;hello&#8217;<br>&nbsp; },<br>&nbsp; strictSSL: false,<br>&nbsp; rejectUnauthorized: false,<br>&nbsp; headers:<br>&nbsp; &nbsp;{<br>&nbsp; &#8216;cache-control&#8217;: &#8216;no-cache&#8217; }<br>&nbsp; &nbsp;};<\/p>\n\n\n\n<p>request(options, function (error, response, body) {<br>&nbsp; if (error) throw new Error(error);<\/p>\n\n\n\n<p>&nbsp; console.log(body);<br>});<\/p>\n\n\n\n<p><strong><br>*******SAMPLE CODE : JAVA*******<\/strong><br><br>import java.io.BufferedReader;<br>import java.io.InputStreamReader;<br>import java.io.OutputStreamWriter;<br>import java.net.HttpURLConnection;<br>import java.net.URL;<br>import java.net.URLEncoder;<br>import java.util.Date;<\/p>\n\n\n\n<p>public class SMSSend {<br>public static void main(String[] args)<br>{ try {<br>Date mydate = new Date(System.currentTimeMillis());<\/p>\n\n\n\n<p>URL url = new URL(&#8220;<a href=\"https:\/\/bulksmsindia.app\/V2\/http-api.php?apikey=xxxxxxxxxxxxxxxxxxxx&amp;senderid=xxxxxx&amp;number=xxxxxxxxxx&amp;message=hello\" target=\"_blank\" rel=\"noreferrer noopener\">https:\/\/bulksmsindia.app\/V2\/http-api.php?apikey=xxxxxxxxxxxxxxxxxxxx&amp;senderid=xxxxxx&amp;number=xxxxxxxxxx&amp;message=hello<\/a>&#8220;);<br>HttpURLConnection conn = (HttpURLConnection)url.openConnection();<br>conn.setRequestMethod(&#8220;GET&#8221;);<br>conn.setDoOutput(true);<br>conn.setDoInput(true);<br>conn.setUseCaches(false);<br>conn.connect();<br>BufferedReader rd = new BufferedReader(new InputStreamReader(conn.getInputStream()));<br>String line;<br>StringBuffer buffer = new StringBuffer();<br>while ((line = rd.readLine()) != null)<br>{<br>buffer.append(line).append(&#8220;\\n&#8221;);<br>}<br>System.out.println(buffer.toString());<br>rd.close();<br>conn.disconnect();<br>}catch(Exception e)<br>{e<br>.printStackTrace();<br>}<br>}}<br>Note: Required javax.servlet.jar and jdom.jar to execute (downloadable from internet,add to classpath).<\/p>\n\n\n\n<p><strong>*******SAMPLE CODE : C#*******<\/strong><\/p>\n\n\n\n<p>var client = new RestClient(&#8220;<a href=\"https:\/\/bulksmsindia.app\/V2\/http-api.php?apikey=xxxxxxxxxxxxxxxxxxxx&amp;senderid=xxxxxx&amp;number=xxxxxxxxxx&amp;message=hello\" target=\"_blank\" rel=\"noreferrer noopener\">https:\/\/bulksmsindia.app\/V2\/http-api.php?apikey=xxxxxxxxxxxxxxxxxxxx&amp;senderid=xxxxxx&amp;number=xxxxxxxxxx&amp;message=hello<\/a>&#8220;);<br>var request = new RestRequest(Method.POST);<br>request.AddHeader(&#8220;cache-control&#8221;, &#8220;no-cache&#8221;);<br>IRestResponse response = client.Execute(request);\n\n<\/p>\n\n\n\n<p><br> <\/p>\n","protected":false},"excerpt":{"rendered":"<p>Bulk SMS API is a string, plays an important role to integrate any application to messaging platform. It secure your data and protects your application or software to access with proper mobile authentication. Mobile number authenticated through the OTP (One Time Password) verification. This is the example of HTTP String : https:\/\/bulksmsindia.app\/V2\/http-api.php?apikey=xxxxxxxxxxxxxxxxx&amp;senderid=xxxxxx&amp;number=xxxxxxxxxx,xxxxxxxxxxX&amp;message=hello This API is [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":38,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"ocean_post_layout":"","ocean_both_sidebars_style":"","ocean_both_sidebars_content_width":0,"ocean_both_sidebars_sidebars_width":0,"ocean_sidebar":"","ocean_second_sidebar":"","ocean_disable_margins":"enable","ocean_add_body_class":"","ocean_shortcode_before_top_bar":"","ocean_shortcode_after_top_bar":"","ocean_shortcode_before_header":"","ocean_shortcode_after_header":"","ocean_has_shortcode":"","ocean_shortcode_after_title":"","ocean_shortcode_before_footer_widgets":"","ocean_shortcode_after_footer_widgets":"","ocean_shortcode_before_footer_bottom":"","ocean_shortcode_after_footer_bottom":"","ocean_display_top_bar":"default","ocean_display_header":"default","ocean_header_style":"","ocean_center_header_left_menu":"","ocean_custom_header_template":"","ocean_custom_logo":0,"ocean_custom_retina_logo":0,"ocean_custom_logo_max_width":0,"ocean_custom_logo_tablet_max_width":0,"ocean_custom_logo_mobile_max_width":0,"ocean_custom_logo_max_height":0,"ocean_custom_logo_tablet_max_height":0,"ocean_custom_logo_mobile_max_height":0,"ocean_header_custom_menu":"","ocean_menu_typo_font_family":"","ocean_menu_typo_font_subset":"","ocean_menu_typo_font_size":0,"ocean_menu_typo_font_size_tablet":0,"ocean_menu_typo_font_size_mobile":0,"ocean_menu_typo_font_size_unit":"px","ocean_menu_typo_font_weight":"","ocean_menu_typo_font_weight_tablet":"","ocean_menu_typo_font_weight_mobile":"","ocean_menu_typo_transform":"","ocean_menu_typo_transform_tablet":"","ocean_menu_typo_transform_mobile":"","ocean_menu_typo_line_height":0,"ocean_menu_typo_line_height_tablet":0,"ocean_menu_typo_line_height_mobile":0,"ocean_menu_typo_line_height_unit":"","ocean_menu_typo_spacing":0,"ocean_menu_typo_spacing_tablet":0,"ocean_menu_typo_spacing_mobile":0,"ocean_menu_typo_spacing_unit":"","ocean_menu_link_color":"","ocean_menu_link_color_hover":"","ocean_menu_link_color_active":"","ocean_menu_link_background":"","ocean_menu_link_hover_background":"","ocean_menu_link_active_background":"","ocean_menu_social_links_bg":"","ocean_menu_social_hover_links_bg":"","ocean_menu_social_links_color":"","ocean_menu_social_hover_links_color":"","ocean_disable_title":"default","ocean_disable_heading":"default","ocean_post_title":"","ocean_post_subheading":"","ocean_post_title_style":"","ocean_post_title_background_color":"","ocean_post_title_background":0,"ocean_post_title_bg_image_position":"","ocean_post_title_bg_image_attachment":"","ocean_post_title_bg_image_repeat":"","ocean_post_title_bg_image_size":"","ocean_post_title_height":0,"ocean_post_title_bg_overlay":0.5,"ocean_post_title_bg_overlay_color":"","ocean_disable_breadcrumbs":"default","ocean_breadcrumbs_color":"","ocean_breadcrumbs_separator_color":"","ocean_breadcrumbs_links_color":"","ocean_breadcrumbs_links_hover_color":"","ocean_display_footer_widgets":"default","ocean_display_footer_bottom":"default","ocean_custom_footer_template":"","ocean_post_oembed":"","ocean_post_self_hosted_media":"","ocean_post_video_embed":"","ocean_link_format":"","ocean_link_format_target":"self","ocean_quote_format":"","ocean_quote_format_link":"post","ocean_gallery_link_images":"on","ocean_gallery_id":[],"footnotes":""},"categories":[1],"tags":[42,41],"class_list":["post-37","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-news","tag-sample-api-codes","tag-what-is-http-api","entry","has-media"],"acf":[],"_links":{"self":[{"href":"https:\/\/www.osdigital.in\/blog\/wp-json\/wp\/v2\/posts\/37","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.osdigital.in\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.osdigital.in\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.osdigital.in\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.osdigital.in\/blog\/wp-json\/wp\/v2\/comments?post=37"}],"version-history":[{"count":4,"href":"https:\/\/www.osdigital.in\/blog\/wp-json\/wp\/v2\/posts\/37\/revisions"}],"predecessor-version":[{"id":69,"href":"https:\/\/www.osdigital.in\/blog\/wp-json\/wp\/v2\/posts\/37\/revisions\/69"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.osdigital.in\/blog\/wp-json\/wp\/v2\/media\/38"}],"wp:attachment":[{"href":"https:\/\/www.osdigital.in\/blog\/wp-json\/wp\/v2\/media?parent=37"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.osdigital.in\/blog\/wp-json\/wp\/v2\/categories?post=37"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.osdigital.in\/blog\/wp-json\/wp\/v2\/tags?post=37"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}