-2
我想通過Ajax函數發送函數中的cUrl請求。通過ajax發送cUrl函數中的函數參數
這是我cUrl作者請求:
function cUrlConnection ($url, $username, $password, $ch) {
$pass = md5($password);
$data = array(
'username' => $username,
'password'=> $pass,
);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (X11; U; Linux i686; pl; rv:1.8.0.4) Gecko/20060426 Firefox/1.5.0.4');
curl_setopt($ch, CURLOPT_TIMEOUT, '40');
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
curl_setopt($ch, CURLOPT_HEADER, 0);
$result = curl_exec($ch);
$pos = strpos($result, "התחברת בהצלחה");
if ($pos === false) {
return false;
}
else
{
return $ch;
}
}
$chs = cUrlConnection($url, $username, $password, $ch);
我想與函數發送變量$ CHS,通過Ajax的另一個文件。 我該怎麼做?
請在啓動$ CH = curl_init($網址)的使用;你還沒有初始化$ ch –
這是正確的,我添加了這個,但在這裏我隱藏它。 –