[英]Curl with Post not working Php ?
well the problem is the simple this today not working ! 好吧问题是这个简单,今天不行!
<?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; }
?>
now when i am using this code : 现在,当我使用此代码时:
<?php
$cv = load('https://localhost/a/ac.php?a=io',array('cookie' => $fbcook,'referer' => $ref,'post_data' => 'odl=lop&isi=837&io'));
echo $cv;
?>
but i am getting error : 但我得到错误:
Fatal error: Call to undefined function curl_setpot() in C:\\xampp\\htdocs\\a\\mack\\curl.php on line 41 致命错误:在第41行的C:\\ xampp \\ htdocs \\ a \\ mack \\ curl.php中调用未定义的函数curl_setpot()
Please help me ! 请帮我 ! why this happning this line 42 indicates this line curl_setpot($curl ,CURLOPT_POSTFIELDS ,$got['post_data']); }
为什么这条线42的开头表示这条线curl_setpot($curl ,CURLOPT_POSTFIELDS ,$got['post_data']); }
curl_setpot($curl ,CURLOPT_POSTFIELDS ,$got['post_data']); }
thanks 谢谢
简单的拼写错误:curl_setpot应该是curl_setopt
curl_setpot
应该是curl_setopt
。
When a function of cURL is undefined, then it is most likely that cURL is not available. 如果未定义cURL的函数,则很可能cURL不可用。
However, I think that you meant curl_setopt()
. 但是,我认为你的意思是curl_setopt()
。
You use xampp so you need to activate curl lib by following these steps: 您使用xampp,因此您需要按照以下步骤激活curl lib:
php/php.ini
(probably C:\\xampp\\php\\php.ini or C:\\program files\\apachefriends\\xampp\\php\\php.ini) 打开php/php.ini
(可能是C:\\ xampp \\ php \\ php.ini或C:\\ program files \\ apachefriends \\ xampp \\ php \\ php.ini) ;extension=php_curl.dll
. 在删除之前: ;extension=php_curl.dll
。 After removing: extension=php_curl.dll
删除后: extension=php_curl.dll
apache/bin/php.ini
(probably C:\\xampp\\apache\\php.ini or C:\\ program files\\apachefriends\\xampp\\apache\\php.ini) 打开apache/bin/php.ini
(可能是C:\\ xampp \\ apache \\ php.ini或C:\\ program files \\ apachefriends \\ xampp \\ apache \\ php.ini) Good luck 祝好运
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.