2011-10-09 83 views
2

以及問題是今天簡單這個不工作!捲髮不起作用PHP?

<?php 

function cload($url, $got = array()){ 

//include(MDL.'socket_adapter.php'); 
$user_agent = "Mozilla/5.0 (Windows NT 6.1; WOW64; rv:5.0) Gecko/20100101 Firefox/5.0"; 

$default_options = array(
    'data'   => 'og', 
    'post_data'  => false, 
    'referer'  => false, 
    'cookie'   => false, 
    'auth'    => false, 
    'proxy'   => false, 
    'pauth'   => false, 
    'returndata'  => true, 
); 

foreach($default_options as $opt=>$value) { 
if(!empty($default_options[$opt])) {$got[$opt] = $value; } 
//if(!empty($got[$opt])) {$got[$opt] = $value;  } 
} 

//echo "<hr>";  print_r($got);  echo "<hr>"; 

$curl = curl_init(); 
//if(strstr($referer,"://")){ 
//curl_setopt ($curl, CURLOPT_REFERER, $got['referer']);} 
curl_setopt ($curl, CURLOPT_URL, $url); 
curl_setopt ($curl, CURLOPT_USERAGENT, $user_agent); 
curl_setopt ($curl, CURLOPT_HEADER, 1); 
if(isset($got['returndata'])){ 
curl_setopt ($curl, CURLOPT_RETURNTRANSFER, 1); 
}else{ 
curl_setopt ($curl, CURLOPT_RETURNTRANSFER, false); 
} 
curl_setopt ($curl, CURLOPT_ENCODING, 'gzip, deflate'); 
curl_setopt ($curl, CURLOPT_SSL_VERIFYPEER, false); 

    if(isset($got['post_data'])){ curl_setopt($curl ,CURLOPT_POST , true); 
    curl_setpot($curl ,CURLOPT_POSTFIELDS ,$got['post_data']); } 
    if(isset($got['referer'])) curl_setopt($curl,CURLOPT_REFERER, $got['referer']); 
    if(isset($got['cookie'])){ if($got['cookie'] == "0"){ 
    curl_setopt($curl ,CURLOPT_COOKIEJAR, TBP."cookie.txt"); }//If ever needed... 
    else{ 
    curl_setopt($curl ,CURLOPT_COOKIE, $got['cookie']); }} 


    $custom_headers = array(); 
    $custom_headers[] = "Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"; 
    $custom_headers[] = "Pragma: no-cache"; 
    $custom_headers[] = "Cache-Control: no-cache"; 
    $custom_headers[] = "Accept-Language: en-us;q=0.7,en;q=0.3"; 
    $custom_headers[] = "Accept-Charset: utf-8,windows-1251;q=0.7,*;q=0.7"; 
    if(isset($url_parts['user']) and isset($url_parts['pass'])) { 
     $custom_headers[] = "Authorization: Basic ".base64_encode($url_parts['user'].':'.$url_parts['pass']); 
    }elseif(isset($got['auth'])){ 
    $uj = explode(":",$got['auth']); $custom_headers[] = "Authorization: Basic ".base64_encode($uj[0].':'.$uj[1]); } 
    if(isset($got['pauth'])){ 
     curl_setopt($curl ,CURLOPT_PROXYUSERPWD ,$pauth); } 
    if(isset($got['proxy'])){ 
     curl_setopt($curl ,CURLOPT_PROXY ,$proxy); } 

    curl_setopt($curl ,CURLOPT_HTTPHEADER, $custom_headers); 
    //curl_setopt($curl, CURLINFO_HEADER_OUT, true); 

    $response = curl_exec($curl); 
    $info = curl_getinfo($curl);// , CURLINFO_HEADER_OUT); 
curl_close ($curl); 

//echo "<hr>"; echo $info; echo "<hr>"; 

    return $response; } 

    ?> 

現在,當我使用此代碼:

<?php 
$cv = load('https://localhost/a/ac.php?a=io',array('cookie' => $fbcook,'referer' => $ref,'post_data' => 'odl=lop&isi=837&io')); 
echo $cv; 
?> 

,但我得到的錯誤:

Fatal error: Call to undefined function curl_setpot() in C:\xampp\htdocs\a\mack\curl.php on line 41

請幫幫我!爲什麼這個happning這一行42表示該行curl_setpot($curl ,CURLOPT_POSTFIELDS ,$got['post_data']); }

感謝

回答

3

當cURL的函數未定義時,很有可能cURL不可用。

但是,我認爲你的意思是curl_setopt()

5

簡單的拼寫錯誤:curl_setpot應該curl_setopt

+4

我想我真的想要有一種叫做curl_setpot()的方法。 – cori

+2

你是一個綠色的拇指位? – Scuzzy

3

curl_setpot應該curl_setopt

2

您使用XAMPP,所以你需要按照以下步驟激活捲曲lib目錄下:

  1. 找到XAMPP安裝目錄
  2. 打開php/php.ini(可能是C:\ XAMPP \ PHP \ php.ini中 或C: \ program files \ apachefriends \ xampp \ php \ php.ini)
  3. 搜索單詞'curl'並取消註釋(刪除前導分號)該行。刪除之前:;extension=php_curl.dll。取出後:extension=php_curl.dll
  4. 保存並關閉
  5. 打開apache/bin/php.ini(可能是C:\ XAMPP的\ apache的\ php.ini中 或C:\ Program Files文件\ apachefriends \ XAMPP的\ apache的\ php.ini中)
  6. 搜索捲曲,取消以前一樣(步驟3)
  7. 保存並關閉
  8. 不要忘了重新啓動Apache

好運