I use cURL to get an rss feed from my own wordpress blog to display it as a “feed” sidebar and when I get the headers, all quotes appear as this : ’
The cURL code I use to get that is:
$ch = curl_init($feed_url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 0);
curl_setopt($ch, CURLOPT_FAILONERROR, true);
curl_setopt($ch, CURLOPT_ENCODING, "");
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($ch, CURLOPT_AUTOREFERER, true);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 2);
curl_setopt($ch, CURLOPT_TRANSFERTEXT, 1);
curl_setopt($ch, CURLOPT_TIMEOUT, 15);
curl_setopt($ch, CURLOPT_HEADER, false);
$content = curl_exec($ch);
The strange thing is that in my local server, it brings the quotes ok, but on the remote, it returns this seq.
The code I use to print out the “Feed” follows:
$x = new SimpleXmlElement($content);
foreach ($x->channel->item as $entry) {
echo "<li class='newsLI'><a href='$entry->link' title='$entry->title'>" . $entry->title . "</a></li>";
}
and what I get, can be clearly seen in the bottom left side of the screen here:
http://www.inlinkz.com
Any ideas on where to start looking for an answer?
Thanks in advance!
DOCTYPEdefinedcontent-typeAdding the following lines to your code solved your problem (at least on my machine ;)):
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN""http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
(of course, this should be set to whatever definition you’re actually using)
<meta http-equiv="content-type"content="text/html;charset=utf-8" />