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

$url = "https://api.authy.com/protected/json/phones/verification/check?api_key=8x3866hQGZVpRQdojnrO0CGOxNk3YXGx&phone_number=$phone&country_code=$country&verification_code=$code";

$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: eFvoT7WPTo6EEdr7O7jHBxlv0AhyZzDz'));
//curl_setopt($curlObj, CURLOPT_POST, 1);
//curl_setopt($curlObj, CURLOPT_POSTFIELDS, array("via: sms", "phone_number: $phone.", "country_code: $country"));



$response = curl_exec($curlObj);


// 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);



}			
