Turns out I was being a silly billy and I introduced a bug into my community check scripts. But the error's now fixed and I'm back to fetching.
Still, it's time to revamp the comment checker:
- One page for all checking and displaying of latest comments.
- One page managing all the communities I check.
- Make it into a class so it can be presented to somewhere like lj_nifty.
Here's my PHP function (simplified) for fetching a pages from LJ with auth digest, with the $url being just a simple one, such as "community.livejournal.com/write_away/20
function fetchLJPage( $url )
$passwd_string = "$ljUsername:$ljUserpass";
$url = "http://$passwd_string@$url?auth=digest";
$ch = curl_init();
curl_setopt($ch, CURLOPT_TIMEOUT, 30);
curl_setopt($ch, CURLOPT_HEADER, 1);
curl_setopt($ch, CURLOPT_VERBOSE, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($ch, CURLOPT_USERPWD, $passwd_string);
curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_DIGEST);
curl_setopt($ch, CURLOPT_URL, $url);
$returned = curl_exec($ch);
if( curl_error( $ch ))
print "<p><b>CURL ERROR (". curl_errno($ch) ."):</b> " . curl_error( $ch ) . "</p>";
Note that if you want to add extra options at the end, like style=mine, or use a URL with a #ending
, you'll have to change the code and take the "?auth=digest" off the end of $url and add it yourself, like I do.