I am writing a php script with a curl request to api in order to get the shipping cost.
Here is the function:
function methodCurl($to,$weight,$price) { $baseUrl = "http://api.postcalc.ru/?"; $baseUrl .= $this->indexFrom; if(!empty($to)){ $to = rawurlencode ($to); $baseUrl .= "&t=".$to; } if(!empty($weight)){ $baseUrl .= "&w=".$weight; } $baseUrl .= $this->country; $baseUrl .= "&o=php"; echo $baseUrl . "<br>"; $ch = curl_init($baseUrl); curl_setopt($ch,CURLOPT_HEADER,0); curl_setopt($ch,CURLOPT_RETURNTRANSFER,1); curl_setopt($ch,CURLOPT_SSL_VERIFYPEER,0); curl_setopt($ch,CURLOPT_USERAGENT,$_SERVER['HTTP_USER_AGENT']); $result = curl_exec($ch); $info = curl_getinfo($ch); $err = curl_error($ch); $errmsg = curl_errno($ch); $info['result'] = $result; $info['error'] = $err; $info['errormsg'] = $errmsg; if($info['http_code'] == 200){ echo mb_detect_encoding($info['result']) . "</br>"; echo "<pre>"; print_r($info); echo "</pre>"; } } And everything seems to be good, the request is formed correctly (if the received request is inserted into the browser, everything opens normally), but when outputting the result through a script, the crap is displayed:
Encoding checked everywhere - utf-8. What could be the problem?
