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;
}
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章