2014-02-20 109 views
3

我想在此cURL請求中僞造useragent。可能嗎?如何在cURL中設置useragent

$options = array(
    CURLOPT_AUTOREFERER => true, 
    CURLOPT_FOLLOWLOCATION => true, 
    CURLOPT_RETURNTRANSFER => true, 
    CURLOPT_COOKIEFILE => $cookie, 
    CURLOPT_COOKIEJAR => $cookie, 
    CURLOPT_SSL_VERIFYPEER => 0, 
    CURLOPT_SSL_VERIFYHOST => 0 
); 

回答

2

像這樣:

$useragent="Your UserAgent string goes here"; 
$options = array(
    CURLOPT_USERAGENT => $useragent, 
    CURLOPT_AUTOREFERER => true, 
    CURLOPT_FOLLOWLOCATION => true, 
    CURLOPT_RETURNTRANSFER => true, 
    CURLOPT_COOKIEFILE => $cookie, 
    CURLOPT_COOKIEJAR => $cookie, 
    CURLOPT_SSL_VERIFYPEER => 0, 
    CURLOPT_SSL_VERIFYHOST => 0 
); 
+1

謝謝!我之前嘗試過,但它沒有工作,現在它工作正常! – user3333334