php模拟post提交提交json数据

"test001",
    "pass"=>"xxxx",
);
$data = json_encode($param); 
list($return_code, $return_content) = http_post_data($url, $data);//return_code是http状态码
print_r($return_content);exit;
function http_post_data($url, $data_string) {
    $ch = curl_init();
    curl_setopt($ch, CURLOPT_POST, 1);
    curl_setopt($ch, CURLOPT_URL, $url);
    curl_setopt($ch, CURLOPT_POSTFIELDS, $data_string);
    curl_setopt($ch, CURLOPT_HTTPHEADER, array(
        "Content-Type: application/json; charset=utf-8",
        "Content-Length: " . strlen($data_string))
    );
    ob_start();
    curl_exec($ch);
    $return_content = ob_get_contents();
    ob_end_clean();
    $return_code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
    return array($return_code, $return_content);
}

当前名称:php模拟post提交提交json数据
文章链接:http://www.hxwzsj.com/article/jpiegi.html

其他资讯

Copyright © 2025 青羊区翔捷宏鑫字牌设计制作工作室(个体工商户) All Rights Reserved 蜀ICP备2025123194号-14
友情链接: 重庆企业网站建设 网站建设 营销网站建设 成都网站建设流程 做网站设计 成都网站建设公司 成都网站设计 成都营销网站建设 网站建设公司 成都网站设计 网站设计制作 营销型网站建设 成都网站建设 高端品牌网站建设 网站制作 教育网站设计方案 重庆外贸网站建设 手机网站制作 专业网站建设 响应式网站设计方案 成都响应式网站建设公司 成都网站制作公司