<?php
require("lib/config.php");
$phone = $_REQUEST["phone"];
$country = $_REQUEST["country"];
$phone = str_replace(" ", "", $phone);
if($phone != "" && $country != "") {

$url = "https://api.authy.com/protected/json/phones/verification/start?via=sms&phone_number=$phone&country_code=$country";
error_log($url);
$curlObj = curl_init();

curl_setopt($curlObj, CURLOPT_URL, $url);
curl_setopt($curlObj, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($curlObj, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($curlObj, CURLOPT_HEADER, 0);
curl_setopt($curlObj, CURLOPT_HTTPHEADER, array('X-Authy-API-Key: 8x3866hQGZVpRQdojnrO0CGOxNk3YXGx'));
curl_setopt($curlObj, CURLOPT_POST, 1);
//curl_setopt($curlObj, CURLOPT_POSTFIELDS, array("via: sms", "phone_number: $phone.", "country_code: $country"));



$response = curl_exec($curlObj);
error_log($response);

// Change the response json string to object
$json = json_decode($response, true);

$Res["message"] = $json["message"];
$Res["status"] = $json["success"];

echo json_encode($Res, true);

curl_close($curlObj);



}			
