我想将post方法形式转换为curl命令 [英] I want to convert a post method form to curl command

查看:69
本文介绍了我想将post方法形式转换为curl命令的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在制作一个自动短信系统。但是SMS提供商给了我邮政方法表格,但是我想用我自己的curl命令对其进行修改。

I'm making an auto SMS system. But SMS provider gave me post method form but I want it to modify with curl command by my own.

他们提供了我

<head>
<title>SMS</title>
</head>

<body>

    <form name="sms" method="post" > 
        <input type="text"  placeholder="send to number" name="to" /><br />
        <input type="textarea"  placeholder="sms" name="msg" /><br />
        <input type="submit" value=" OK " />
    </form>

    <?php     
     $apikey='$2y$10$t..Yr.YDG0kXYiuLwQ78OecDgz6/qh.1xSWx77mXjczkk3AEKvTZe';

     if (isset($_POST["msg"]) ) {
         $sendto = $_POST["to"];
         $fullNumber = '880' . substr(preg_replace('/\D/', '', $sendto), -10);
         $msg = urlencode($_POST["msg"]);
         // $masking='CITY PORTER';
         // $masking=urlencode($masking);
         // masking $url='http://example.com/smsapi/masking?api_key='.$apikey.'&smsType=text&maskingID='.$masking.'&mobileNo='.$fullNumber.'&smsContent='.$msg.'';

         $url='http://example.com/smsapi/non-masking?api_key='.$apikey.'&smsType=text&mobileNo='.$fullNumber.'&smsContent='.$msg.'';

         if ( !empty($_POST["to"])  && !empty($_POST["msg"])) {
             $curl = curl_init();

             curl_setopt_array($curl, array(
                 CURLOPT_RETURNTRANSFER => 1,
                 CURLOPT_URL =>$url,
                 CURLOPT_USERAGENT =>'My Browser'
             ));

             $resp = curl_exec($curl);
             echo $resp;
             curl_close($curl);

         } 

         else

        { echo "Field is empty";}

     }

   ?>
</body>

我将其转换为curl命令,但这仍然无法正常工作。我只想输入不带set()1值的多个值。

I converted it to curl command but this is not still working. I just want to input multiple value without is set() 1 value.

$api_key = "$2y$10$mtW.yfKj18i2mTPe/0iCEuKdCfCGh9zOYYEU9AmnMrJyBb.h7fVcG";
$number = $row[mailing_no]; 
$message = "Dear Guardian, ". $row[name] . " has swiped his card right now";
$type= "text";
$params = array('api_key'=>$api_key, 'smsType'=>$type, 'mobileNo'=>$number, 'smsContent'=>$message);

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "http://example.com/smsapi/non-masking?".http_build_query($params, "", "&"));
curl_setopt($ch, CURLOPT_HTTPHEADER, array("Content-Type:application/json", "Accept:application/json"));
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, TRUE);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);

$response = curl_exec($ch);
curl_close ($ch);


推荐答案

尝试一下,希望您的问题得到解决

Try this i hope your problem will be solve

<div id="send_reply"></div>
<form name="sms" method="post" > 
    <input type="text"  placeholder="send to number" name="to" id="phone" /><br />
    <input type="textarea"  placeholder="sms" name="msg" id="mess" /><br />
    <input type="submit" value=" OK " id="send_btn" />
</form>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
<script type="text/javascript">
    $(document).ready(function(){
        $("#send_btn").click(function(){
            var txt1=$("#phone").val();
            var txt2=$("#mess").val();
            $.ajax({
                url : 'check.php',
                method : 'GET',
                data : {txt1:txt1,txt2:txt2},
                success:function(dda){
                    $("#send_reply").html(dda);
                }
            });
        });

    });
</script>

这篇关于我想将post方法形式转换为curl命令的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆