curl post 函数

 1 function curl_post($url,$post_data){
 2     if(empty($url) || !is_array($post_data)){
 3         return false;
 4     }
 5     $ch = curl_init(); 
 6     curl_setopt($ch, CURLOPT_POST, 1);
 7     curl_setopt($ch, CURLOPT_URL,$url);
 8     curl_setopt($ch, CURLOPT_POSTFIELDS, $post_data);
 9     ob_start();
10     curl_exec($ch);
11     $result = ob_get_contents() ;
12     ob_end_clean();
13     return $result;
14 }

 


手册:
http://cn2.php.net/manual/zh/ref.curl.php
posted @ 2014-01-01 23:07  JasonBao  阅读(260)  评论(0编辑  收藏  举报