PHPpost 请求

header 请求类型不一样哦 根据自己情况 修改

function send_post($url, $post_data) {
    //$postdata = http_build_query($post_data);
    $postdata = json_encode($post_data);
   // print_r($postdata);die;
    $options = array(
        'http' => array(
            'method' => 'POST',
            'header' => 'Content-type:application/json; charset=utf-8', //             //application/x-www.form-urlencoded
            'content' => $postdata,
            'timeout' => 15 * 60 // 超时时间(单位:s)
        )
    );
    $context = stream_context_create($options);
    $result = file_get_contents($url, false, $context);


    return $result;
}

你可能感兴趣的:(php)