0

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;
2
  • What's the error you're getting? Commented Sep 7, 2012 at 21:44
  • no error. it works for other feeds.. Commented Sep 7, 2012 at 21:58

2 Answers 2

2

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);
Sign up to request clarification or add additional context in comments.

3 Comments

+1 for curl_error(). Also, adding this shows that it can't validate the cert [Peer certificate cannot be authenticated with given CA certificates]. So changing https:// to http:// fixes that and you're feed contents is returned as expected.
I tried changing the link to http.. but no luck.. i have curl enabled on my server. also i tried putting curl_error().. it gives nothing.. can anyone of u check if it works on your server?. I really appreciate your help on this.
@Samarth, your original code worked for me having just changed https to http.
0

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.