php curl的几种用法
æ»ç»ä¸ä¸é¡¹ç®ä¸ç¨å°curlçå ç§æ¹å¼
1. php curlçé»è®¤è°ç¨æ¹æ³ï¼getæ¹å¼è®¿é®url
....
$ch = curl_init();
curl_setopt($ch, CURLOPT_HTTPHEADER, $header); //设置http头
curl_setopt($ch, CURLOPT_ENCODING, "gzip" ); //设置为客æ·ç«¯æ¯ægzipå缩
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 30 ); //设置è¿æ¥çå¾
æ¶é´
curl_setopt($ch, CURLOPT_URL, $url );
curl_exec( $ch );
if ($error = curl_error($ch) ) {
//åºéå¤ç
return -1;
}
fclose($fp);
$curl_code = curl_getinfo($ch, CURLINFO_HTTP_CODE); //è·åhttpè¿åå¼
if( $curl_code == 200 ) {
//æ£å¸¸è®¿é®url
}
//å¼å¸¸