Skip to content

Instantly share code, notes, and snippets.

@iogi
Created January 2, 2010 12:50
Show Gist options
  • Save iogi/267483 to your computer and use it in GitHub Desktop.
Save iogi/267483 to your computer and use it in GitHub Desktop.
<?php
$url = "http://d.hatena.ne.jp/i_ogi/atom/blog";
$user_name = "your hatena id";
$password = "your password";
$nonce = md5(mt_rand());
$created = date(DATE_ISO8601);
$x_wsse = sprintf('UsernameToken Username="%s", PasswordDigest="%s", Nonce="%s", Created="%s"',
$user_name,
base64_encode(sha1($nonce . $created . $password, true)),
base64_encode($nonce),
$created);
$context = stream_context_create(
array('http' => array('header' => "X-WSSE: $x_wsse"))
);
echo file_get_contents($url, 0, $context);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment