With this script you can access your private marks in news aggregators which support Basic HTTP authentication (tested with FeedDemon?).
<?php
if ( !isset($_SERVER['PHP_AUTH_USER']) ) {
header('WWW-Authenticate: Basic realm="My Realm"');
header('HTTP/1.0 401 Unauthorized');
echo 'Unauthorized';
die();
} else {
// header('Content-type: application/atom+xml');
header('Content-type: text/xml');
$Username = $_SERVER['PHP_AUTH_USER'];
$Password = $_SERVER['PHP_AUTH_PW'];
$Nonce = rand( 1 , 100000000000000 );
$CreationTimestamp = date('Y-m-d\Th:i:s\Z');
$PasswordHash = md5( $Password );
$PasswordDigest = base64_encode( sha1( $Nonce . $CreationTimestamp . $PasswordHash ) );
require_once "HTTP/Request.php";
$req =& new HTTP_Request('http://api.blogmarks.net/marks?private=true&author=' . $Username . '&last=30');
$req->setMethod(HTTP_REQUEST_METHOD_GET);
$req->addHeader('Accept', 'application/atom+xml');
$req->addHeader('X-WSSE', 'UsernameToken Username="' . $Username . '", PasswordDigest="' . $PasswordDigest . '", Nonce="' . $Nonce . '", Created="' . $CreationTimestamp . '"');
$response = $req->sendRequest();
if (PEAR::isError($response)) {
echo $response->getMessage();
} else {
echo $req->getResponseBody();
}
}
?>
Attachments
- MyMarks.php (1.2 kB) - added by znarf on 03/23/05 18:51:08.
- MyMarks+pear.zip (126.9 kB) - added by znarf on 03/23/05 18:53:19.
