0
我試圖使用cURL獲取頁面數據並通過POST發送變量。這是代碼。使用cURL獲取頁面數據
$kayako['url'] . '/Core/Default/Login';
$fields = array(
'username'=>urlencode("username"),
'password'=>urlencode("password")
);
foreach($fields as $key=>$value) {
$fields_string .= $key.'='.$value.'&';
}
rtrim($fields_string,'&');
$ch = curl_init();
curl_setopt($ch,CURLOPT_URL,$url);
curl_setopt($ch,CURLOPT_POST,2);
curl_setopt($ch,CURLOPT_POSTFIELDS,$fields_string);
curl_setopt($ch,CURLOPT_USERAGENT,$_SERVER['HTTP_USER_AGENT']);
curl_setopt($ch,CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
$xml = curl_exec($ch);
curl_close($ch);
我設置看看有什麼出來(生)由
print_r($xml);
然而,頁面顯示亂碼編碼給我。
我在做什麼錯?