trackpopular
trackpopular

Reputation: 61

Error parsing XML feed from my wordpress blog using php curl

https://blog.onlywire.com/category/content-submission/feed/

This is my feed URL. For some reason, I am not able to parse it using PHP. What am I missing?

The script:

$ch = curl_init( $feed_curl );
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HEADER, 0);
$data = curl_exec($ch);
echo $data;

Upvotes: 0

Views: 287

Answers (2)

Thomas Sahlin
Thomas Sahlin

Reputation: 796

Try specifying a file of root CAs:

curl_setopt($ch, CURLOPT_CAINFO, '/path/to/your/cafile');

You can download a CA file from the curl website:

http://curl.haxx.se/docs/caextract.html

Upvotes: 0

Traveling Tech Guy
Traveling Tech Guy

Reputation: 27811

Try to see if you're getting any curl error - and don't forget to close the handler!

        $ch = curl_init($url);
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE); // return into a variable
        curl_setopt($ch, CURLOPT_HEADER, 0);
        $result = curl_exec($ch); // run!
        if($result === FALSE) {
            var_dump(curl_error($ch));
        }
        else {
            var_dump($result);
        }
        curl_close($ch);

Upvotes: 2

Related Questions