Curlpost and get code
Function curl_post_contents ($ url, $ data = array (), $ cookiepath = '', $ timeout = 10) {$ userAgent = 'mozilla/4.0 + (compatible; + MSIE + 6.0; + Windows + NT + 5.1; + SV1) '; $ referer = $ url; if (! Is_array ($ data) |! $ Url) return ''; $ post =''; foreach ($ data as $ key => $ value) {$ post. = $ key. '= '. urlencode ($ value ). '&';} rtrim ($ post, '&'); $ ch = curl_init (); curl_setopt ($ ch, CURLOPT_URL, $ url ); // Set the url for access curl_setopt ($ ch, CURLOPT_TIMEOUT, $ timeout); // Set the timeout curl_setopt ($ ch, CURLOPT_USERAGENT, $ userAgent ); // user access proxy User-Agentcurl_setopt ($ ch, CURLOPT_REFERER, $ referer); // Set referercurl_setopt ($ ch, CURLOPT_FOLLOWLOCATION, 0); // trace 301curl_setopt ($ ch, CURLOPT_POST, 1); // specify the post data curl_setopt ($ ch, CURLOPT_POSTFIELDS, $ post); // add the variable curl_setopt ($ ch, CURLOPT_COOKIEJAR, $ cookiepath ); // COOKIE storage path. the returned COOKIE storage path curl_setopt ($ ch, CURLOPT_RETURNTRANSFER, 1); // The Returned result $ content = curl_exec ($ ch ); curl_close ($ ch); return $ content;} function curl_get_contents ($ url, $ timeout = 5) {$ ch = curl_init (); curl_setopt ($ ch, CURLOPT_URL, $ url); curl_setopt ($ ch, CURLOPT_TIMEOUT, $ timeout); curl_setopt ($ ch, CURLOPT_USERAGENT, 'mozilla/4.0 (compatible; MSIE 5.01; Windows NT 5.0 )'); curl_setopt ($ ch, CURLOPT_RETURNTRANSFER, true); @ curl_setopt ($ ch, CURLOPT_DNS_USE_GLOBAL_CACHE, true); curl_setopt ($ ch, timeout, 86400 ); // cache $ content = curl_exec ($ ch); curl_close ($ ch); return $ content ;}