ajax函数调用消息发送给出500内部服务器错误

时间:2016-11-26 08:14:23

标签: javascript php jquery ajax

以下代码调用ajax函数将以下代码触发时向用户发送msg给出500内部服务器错误jquery.min.js 这些文件托管在amazon aws中。当在普通的bigrock服务器上测试相同的代码时,它工作正常,当在亚马逊托管它给出500内部服务器错误时。

function sendotp(){
var vl = parseInt($('#otp').val());      
    var contact = $('#contact').val(); 
            //alert(contact);
        $.ajax({
        url: "validation.php", 
        type:'POST',
         data: {
                contact: contact,vals : vl
            },
        success: function(data){

        }
    });

}

以下是validation.php中的php代码

if(isset($_POST['contact']))
{
 $otp = $_POST['vals'];
     $contact_number = explode('-',$_POST['contact']);
     $number = $contact_number[1];
     $sms = "Your OTP Varification Code For Wrap2Earn Registration is ".$otp.".";

/*  sms Integration  */
//Your authentication key
$authKey = "XXXXX";

//Multiple mobiles numbers separated by comma
$mobileNumber = $number;

//Sender ID,While using route4 sender id should be 6 characters long.
$senderId = "XXXXXX";

//Your message to send, Add URL encoding here.
$message = urlencode("$sms");

//Define route
$route = "4";
//Prepare you post parameters
$postData = array(
    'authkey' => $authKey,
    'mobiles' => $mobileNumber,
    'message' => $message,
    'sender' => $senderId,
    'route' => $route
);

//API URL
$url="https://control.msg91.com/api/sendhttp.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);
}

0 个答案:

没有答案