405不允许通过SSL-PHP Ajax Mailchimp API Nginx

405不允许通过SSL-PHP Ajax Mailchimp API Nginx,php,ajax,nginx,http-status-code-405,mailchimp-api-v3.0,Php,Ajax,Nginx,Http Status Code 405,Mailchimp Api V3.0,我构建了一个html web表单,它通过AJAX收集订户信息,并通过php脚本进行处理,然后发送给mailchimp 在将SSL添加到域之前,表单提交工作正常。当我试图提交表格时,我不断地得到405不允许。我不知道出了什么问题。我觉得这与Nginx服务器配置有关,但我不是这方面的专家,也不知道该去哪里找 经过一些研究,我看到了一些帖子,讨论了“Nginx不允许发布静态内容”,我不确定这是否适用于我的案例,因为这个问题只发生在添加ssl之后(我在阿里云上使用Nginx+php)。以下是我的代码:

我构建了一个html web表单,它通过AJAX收集订户信息,并通过php脚本进行处理,然后发送给mailchimp

在将SSL添加到域之前,表单提交工作正常。当我试图提交表格时,我不断地得到405不允许。我不知道出了什么问题。我觉得这与Nginx服务器配置有关,但我不是这方面的专家,也不知道该去哪里找

经过一些研究,我看到了一些帖子,讨论了“Nginx不允许发布静态内容”,我不确定这是否适用于我的案例,因为这个问题只发生在添加ssl之后(我在阿里云上使用Nginx+php)。以下是我的代码:

<section id="mailchimp">
  <div class="container">
    <form id="form" method="POST" action="action.php">
      <p class="sub-lead">* indicates required.</p>
      <input type="email" name="EMAIL" id="form_email" placeholder="Email Address *" required="required">
      <input type="text" name="FNAME" id="form_fname" placeholder="First Name *" required="required">
      <input type="text" name="LNAME" id="form_lname" placeholder="Last Name *" required="required">
      <input type="text" name="PHONE" id="form_phone" placeholder="Phone Number *" required="required">
      <select name="ROOM" id="room">
        <option value="" disabled selected>I am interested in...</option>
        <option value="1 Bedroom">1 Bedroom</option>
        <option value="2 Bedroom">2 Bedroom</option>
        <option value="3 Bedroom">3 Bedroom</option>
      </select>
      <input type="checkbox" id="opt-in" name="opt-in" value="opt-in" required="required">Yes, I want to receive current & future projects info from the development team & its affiliates.<br>
      <input type="submit" value="submit" id="submit">
      <div id="signup-result"></div>
    </form>
  </div>
</section>

错误日志中有任何内容吗?控制台中只显示“405不允许-nginx”,没有其他内容。但是,在没有ssl的情况下进行测试时,表单成功提交,没有任何错误。同时发布您的NGINX配置和错误日志中的任何内容所对应的url?控制台中仅显示“405不允许-NGINX”,没有其他内容。但是,在没有ssl的情况下进行测试时,表单成功提交,没有错误。同时发布您的NGINX配置和正在命中的url
<?php
//fill in these values for with your own information
$api_key = 'xxxxxxxx-us16';
$datacenter = 'us16';
$list_id = 'xxxxxxxxx;
$email = $_POST['email'];
$fname = $_POST['first_name'];
$lname = $_POST['last_name'];
$phone = $_POST['phone'];
$room = $_POST['room'];
$country = $_POST['country'];
$status = 'subscribed';
if(!empty($_POST['status'])){
    $status = $_POST['status'];
}
$url = 'https://'.$datacenter.'.api.mailchimp.com/3.0/lists/'.$list_id.'/members/';
$username = 'apikey';
$password = $api_key;
$data = array("email_address" => $email,
                    "status"  => $status,
                    "merge_fields"  => array(
                            "FNAME" => $fname,
                            "LNAME" => $lname,
                            "PHONE" => $phone,
                            "ROOM"  => $room,
                    )
              );
$data_string = json_encode($data);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,$url);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data_string);
curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
curl_setopt($ch, CURLOPT_USERPWD, "$username:$api_key");
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
    'Content-Type: application/json',
    'Content-Length: ' . strlen($data_string))
);
$result=curl_exec ($ch);
curl_close ($ch);
echo $result;
?>
  // Mailchimp Form
  $('#form').submit(function(e){
    e.preventDefault();

    //grab attributes and values out of the Form
    var data = {
                email: $('#form_email').val(),
                first_name: $('#form_fname').val(),
                last_name: $('#form_lname').val(),
                phone: $('#form_phone').val(),
                room: $('#room').val(),
                };
    var endpoint = $(this).attr('action');

    //make the ajax request
    $.ajax({
      method: 'POST',
      dataType: "json",
      url: endpoint,
      data: data
    }).done(function(data){
      if(data.id){
        //successful adds will have an id attribute on the object
        window.location='thankyou.html'
      } else if (data.title == 'Member Exists') {
        //MC wil send back an error object with "Member Exists" as the title
        alert('It looks like you have already signed up with this email address. If you have any questions, please feel free to contact us by email or phone.');
      } else {
        //something went wrong with the API call
        alert('Oops, we could not reach server at the moment, please try again later.');
      }
    }).fail(function(){
      //the AJAX function returned a non-200, probably a server problem
      alert('oh no, there has been a problem');
    });

  });