在codeigniter中使用phpcurl发送otp不起作用

问题描述 投票:0回答:0

我有一个 codeigniter php 网站,我正在使用一个表单向客户发送 otp,当我在纯 php curly 中测试代码时,otp 运行良好,现在我向 codeigniter 实现了同样的功能,下面是我的代码:

控制器:

$mobile = $details['mobile'];
        $otp=$this->mainModel->generateSMSKey();
    $customerMessage= "One%20Time%20Password%20(OTP)%20to%20complete%20the%20payment%20for%20your%20order%20at%20BookTheParty%20account%3A%20".$otp.".%20If%20you%20have%20any%20further%20questions%20or%20need%20assistance%2C%20please%20don%27t%20hesitate%20to%20reach%20out%20to%20the%20BookTheParty%20Team.%20Thanks%2C%20BookTheParty%20Team.";
       
           $temp_id=xxxxxxxxxxx;
           $this->mainModel->sendOtptoCustomer($mobile,$customerMessage,$temp_id);
           echo "success";

我的型号:

    public function sendOtptoCustomer($mobile,$customerMessage,$temp_id){



$url = "https://dstri.connectbind.com:8443/sendsms/bulksms?username=int9-xxxxx&password=xxxxx&type=0&dlr=1&destination=".$mobile."&source=BTPRTY&message=".$customerMessage."&entityid=1701168552156247140&tempid=".$temp_id;

// Initialize cURL session
$ch = curl_init();

// Set cURL options
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
// curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); 

// Execute cURL session and get the response
$response = curl_exec($ch);

// Check for cURL errors
if (curl_errno($ch)) {
    // Handle cURL error
    $error_message = curl_error($ch);
    // Handle the error accordingly, for example: echo "cURL Error: " . $error_message;
} else {
    // Handle the response
    // The SMS has been sent successfully, you can check the response if needed
    // For example, you can echo $response;
}

// Close cURL session
curl_close($ch);


    }

我的阿贾克斯:

$('#checkout_form').submit(function(e) {

  e.preventDefault();
  var mobile = $("#user_mobile_number").val();
  var customer_email = $(".customer_email").val();
  var customer_name = $(".customer_name").val();
  var qData = {
    mobile: mobile,
    customer_email: customer_email,
    customer_name: customer_name
  };
  $.ajax({
    type: 'POST',
    url: url + 'ajax/sendotp',
    data: qData,
    dataType: "text",
    success: function(resultData) {
      $('#checkout_form').find(':button[type=submit]').prop('disabled', false);
      $('#checkout_form').find(':input[type=submit]').prop('disabled', false);
      if (resultData == 'success') {
        $('.checkout_otp_form').find('input[name="otp"]').val('');
        $('.checkout_otp_form').find('input[name="customer_name"]').val(customer_name);
        $("#checkout-otp").modal('show');
      } else {

        alert("Something went Wrong,Please Try Again");
        return false;
      }
    }
  });
  return false;

});

但是 otp 没有出现,也没有显示错误,任何人都可以告诉我这里可能出了什么问题,提前谢谢

javascript php jquery codeigniter sms
© www.soinside.com 2019 - 2024. All rights reserved.