�ܻؤ�1�顪30�奵��꡼�ޥ�ܥ���������

����IT��Ȥ�Ư��30�奵��꡼�ޥ�Υ��饤�ߥ󥰵�Ͽ

������AtomAPI

����ʥ���֥���AtomAPI���ݤ��ʤ����ε�������������
�����������ϸ��Ƥ��äѤ�Ʊ���褦�˺��äƤ�ͤ�����ߤ�����

�Ȥ����櫓�ǡ��פ��֤��Ĵ��ľ������
����Υ������Ȱ㤦��ʬ��ԥå����åס�
��äѤ�WSSEǧ�����ݥ���ȤǤ��������줵���̤�Ф��ȤϤ���ʤꡣ


$nonce = sha1(md5(time()));


������ʸ�����������鲿�Ǥ⤤���Ȥϻפ����ɡ�


$pass_digest = base64_encode(pack('H*', sha1($nonce.$created.strtolower(md5($password)))));


�����������դ��ä���
��ʸ���ˤ���󤸤�ʤ�����ʸ���ˤ��롣


���Ȥ�get�ǵ������������������η�̤���post����URL��ȤäƵ������ꤲ��ߤ�����

������Ѥ�����������
³�����ɤ�
    ¤³¤Î¥¨¥ó¥È¥ê¡¼¤ò¤Ï¤Æ¤Ê¥Ö¥Ã¥¯¥Þ¡¼¥¯¤ËÄɲÃ

�����livedoorBlog��AtomAPI������˰���³������֥����ä��㤦�����Ȼפä���ϥޤä���
Ʊ��AtomAPI����������Ʊ���ǹԤ���������Ȼפä���㤦�餷����

��������Ĵ�٤Ƥߤ��WSSEǧ�ڤ��ȼ��ݤ���
�Ǥ⤤����Ĵ�٤Ƥ�Ʊ���褦�˺��äƤ�ͤϤ��Ƥ⡢��褷�Ƥ�ͤ����Ĥ���ʤ�����

�ɵ����ݤ��ޤ�������(2010-02-03)  >>������ε����ء�



����ޤ�Ĵ�٤�livedoorBlog�Ȱ㤦�Ȼפ�����ʬ��pass_digest�κ�����ʬ��

livedoorBlog
$pass_digest = base64_encode(pack('H*', sha1($nonce.$created.$password)));

����֥�
$pass_digest = base64_encode(pack('H*', sha1($nonce.$created.strtoupper(md5($password)))));

�ѥ���ɤ�md5�������Ȥ���ʸ��������餷���Ȥξ���
�ǥޤ��ۥ�Ȥ��狼��ޤ��󡣡�

�֤äƤ���쥹�ݥ󥹤�
CurlResponse Object
(
    [body] => 
X-WSSE authentication required
    [headers] => Array
        (
            [Http-Version] => 1.1
            [Status-Code] => 401
            [Status] => 401 Unauthorized
            [Set-Cookie] => BIGipServerPool_comment=3395622060.20480.0000; expires=Sat, 17-Oct-2009 01:32:13 GMT; path=/
            [Date] => Fri, 16 Oct 2009 02:18:33 GMT
            [Server] => Apache
            [Content-Length] => 83
            [Content-Type] => application/x.atom+xml
        )

)

����������ʤ󤫰㤦�Ȥ��Ǵְ�äƤ�Τ���������
������Ѥ��������ɤϰʲ���

³�����ɤ�
    ¤³¤Î¥¨¥ó¥È¥ê¡¼¤ò¤Ï¤Æ¤Ê¥Ö¥Ã¥¯¥Þ¡¼¥¯¤ËÄɲÃ

����ε����˰���³��AtomAPI�ѡ�
PHP��cURL���ѡ�

<?php
require_once 'cURL.php';

$atomapi_url = "http://cms.blog.livedoor.com/atom/";
$livedoor_id = "your livedoor id"; /* livedoorID */
$password = "your password"; /* �ѥ���� */
$category = "1"; /* ���ƥ��� */
$title = "sample"; /* ���������ȥ� */
$text = "content"; /* ������ʸ */

$created = date('Y-m-d\TH:i:s\Z');
$nonce = pack('H*', sha1(md5(time())));
$pass_digest = base64_encode(pack('H*', sha1($nonce.$created.$password)));
$wsse =
  'UsernameToken Username="'.$livedoor_id.'", '.
  'PasswordDigest="'.$pass_digest.'", '.
  'Nonce="'.base64_encode($nonce).'", '.
  'Created="'.$created.'"';

$text64= base64_encode($text);

$rawdata =
  '<?xml version="1.0"?>'.
  '<entry xmlns="http://purl.org/atom/ns#" xmlns:dc="http://purl.org/dc/elements/1.1/">'.
  '<title type="text/html" mode="escaped">'.$title.'</title>'.
  '<dc:subject type="text/html" mode="escaped">'.$category.'</dc:subject>'.
  '<content type="application/xhtml+xml" mode="base64">'.$text64.'</content>'.
  '</entry>';

$headers = array(
              "X-WSSE" => $wsse,
              "Content-Type" => "application/x.atom+xml",
              "Cache-Control" => "no-cache",
              );

$curl = new Curl();
$curl->headers = $headers;
$curl->options = array("POSTFIELDS" => $rawdata);
$res = $curl->post($atomapi_url);
?>
    ¤³¤Î¥¨¥ó¥È¥ê¡¼¤ò¤Ï¤Æ¤Ê¥Ö¥Ã¥¯¥Þ¡¼¥¯¤ËÄɲÃ

¤³¤Î¥Ú¡¼¥¸¤Î¥È¥Ã¥×¥Ø