您当前的位置: 首页 >  php

漏刻有时

暂无认证

  • 0浏览

    0关注

    717博文

    0收益

  • 0浏览

    0点赞

    0打赏

    0留言

私信
关注
热门博文

php和js获取POST参数API接口数据的不同解决方案

漏刻有时 发布时间:2021-03-16 12:55:34 ,浏览量:0

    $.ajax({
        type: 'post',
        async: true,
        data: {
            "security": "终端安全",
            "company": "000100010000",
            "days": 1,
            "rows": 10
        },
        url: 'http://***/Aqfk/api/DataHandler.ashx?license=abc@321',
        dataType: "json",
        success: function (res) {
            console.log(res);
        },
        error: function (err) {
            console.log(err + "请求数据失败!");
        }
    });
function curl_post($url, $data = array())
{
    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL, $url);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
    curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE);
    // POST数据
    curl_setopt($ch, CURLOPT_POST, 1);
    // 把post的变量加上
    curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
    $output = curl_exec($ch);
    curl_close($ch);
    return $output;
}

$url = "http://***/Aqfk/api/DataHandler.ashx?license=abc@321";
$data = array(
    "security" => "边界安全",
    "company" => "000100010000",
    "days" => 1,
    "rows" => 10
);

var_dump(curl_post($url, $data));

lockdatav Done!

关注
打赏
1661217259
查看更多评论
立即登录/注册

微信扫码登录

0.0439s