I’m using Reddit’s API to get votes count for a given URL (I’m doing that like this, http://www.reddit.com/api/info.json?url=$url). I’m always getting Error 500 message. I give you a snippet of my code below. Anyone can help me?
$useragent="Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.1) Gecko/20061204 Firefox/2.0.0.1";
$ch = curl_init();
curl_setopt($ch,CURLOPT_URL,$url);
curl_setopt($ch,CURLOPT_RETURNTRANSFER,1);
curl_setopt($ch,CURLOPT_CONNECTTIMEOUT,15);
curl_setopt($ch, CURLOPT_USERAGENT, $useragent);
$content = curl_exec($ch);
echo $content;
curl_close($ch);
Echo is always returning me the next line.
<html><body><h1>500 Server Error</h1>An internal server error occured.</body></html>
Thanks for reading.
— EDITED —
It is working locally.
reddit’s API rules state the following about user agents:
That doesn’t explain the 500 error, nevertheless, this is where I’d start if the same URL works just fine when you use your browser. If you are getting 500 errors when also using your browser, then you probably aren’t using the
infoAPI correctly (and consequently found a bug).