i want to use one site with API, i have this code:
$ch=curl_init('http://example.com/?api=**');
$options = array(
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_HTTPHEADER => array('text/plain;charset=UTF-8') ,
);
curl_setopt_array( $ch, $options );
$results=curl_exec($ch);
var_dump($results);
but i see ? instead of some characters like ”, » .
i checked source page and charset is utf-8..
what is problem?
I guess you missed the option CURLOPT_ENCODING
Please try following code.
$ch = curl_init('http://example.com/?api=**');
curl_setopt($ch, CURLOPT_HTTPHEADER, 'text/plain;charset=UTF-8');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_ENCODING, 'UTF-8');
$results = curl_exec($ch);
var_dump($results);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With