php 不用通过表单也能创建HTTPpost请求

function post($postdata,$server){
    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL, $server);
    curl_setopt($ch, CURLOPT_HEADER, 0);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt($ch, CURLOPT_POST, 80);
    curl_setopt($ch, CURLOPT_POSTFIELDS, $postdata);
    $data = curl_exec($ch);
    curl_close($ch);
    return $data;
}

 

posted on 2012-11-28 20:19  lsl8966  阅读(229)  评论(0编辑  收藏  举报