Friends, I need a little help. i have my own SMS gateway

Hello Friends,

I need a little help. i have my own SMS gateway for india.

Here is code i m using for sending SMS from my wordpress blow

$usr = "user";
$pwd = "pass";
$sndr = "SenderID";

//Prepare you post parameters
$postData = array(
'usr' => $usr,
'pwd' => $pwd,
'sndr' => $sndr,
'ph' => $_POST['ph'],
'text' => $_POST['text']
);

//API URL
$url="http://sms.mysite.com/unified.php";

// init the resource
$ch = curl_init();
curl_setopt_array($ch, array(
CURLOPT_URL => $url,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_POST => true,
CURLOPT_POSTFIELDS => $postData
//,CURLOPT_FOLLOWLOCATION => true
));

//Ignore SSL certificate verification
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);

//get response
$output = curl_exec($ch);

//Print error if any
if(curl_errno($ch))
{
echo 'error:' . curl_error($ch);
}

curl_close($ch);

echo 'SMS Sent';

Now i want to integrate it with wordpress user Registration

When a user register he must enter the random code sent by the script and wordpress to verify him.

Any help about how to generate the code and store in the DB also sent the code to mobile with the script above through my gateway

Thanks