How to Set Up OTP SMS API in Your Code

Image Placeholder
Note: If you have purchased the OTP service after 1st March 2025, please use the updated API endpoint provided below.

Step 1: Obtain Your API Key

After purchasing the OTP SMS service from DVHosting, log in to your client area to retrieve your unique API key. This key is essential for authenticating your requests to the DVHosting API.

Step 2: Integrate the PHP Code

Use the following PHP code snippet to send an OTP to a user's mobile number. This example utilizes PHP due to its popularity among users, but the API can be integrated using any programming language.

<?php
$mobile = "Enter mobile number here";
$otp = "OTP number to send";
$api_key = "Enter your API key here";

$contextOptions = array(
  "ssl" => array(
    "verify_peer" => false,
    "verify_peer_name" => false,
  ),
);

$otp_url="http://otp.xhost.co.in/submitsms.jsp?user=$dv_user&key=$dv_key&mobile=+91$num&message=Hi%20Dear%2C%20Your%20Otp%20is%20$otp.%20OTP%20request%20for%20OTP.%20Don%27t%20Share%20with%20Anyone.%20Thanks%2C%20Team%20SB%20Genus.&senderid=SBGINF&accusage=1";
$response = file_get_contents($otp_url, false, stream_context_create($arrContextOptions));
?>

Replace Enter mobile number here with the recipient's mobile number, OTP number to send with the OTP you wish to send, and Enter your API key here with your actual API key.