Created
October 15, 2011 06:52
-
-
Save naoya/1289178 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
wsseHeader = require './lib/wsse' | |
request = require 'request' | |
# entry = | |
# url: 'http://d.hatena.ne.jp/naoya/#atompost' | |
# comment: "This is it" | |
# xml = """ | |
# <entry xmlns="http://purl.org/atom/ns#"> | |
# <title>dummy</title> | |
# <link rel="related" type="text/html" href="#{entry.url}" /> | |
# <summary type="text/plain">#{entry.comment}</summary> | |
# </entry> | |
# """ | |
# request | |
# url: 'http://b.hatena.ne.jp/atom/post' | |
# headers: | |
# 'X-WSSE': wsseHeader 'naoya', 'password' | |
# method: 'POST' | |
# body: xml | |
# , (err, response, body) -> | |
# console.log response.statusCode | |
HatenaBookmark = {} | |
HatenaBookmark.post = (entry, callback) -> | |
xml = """ | |
<entry xmlns="http://purl.org/atom/ns#"> | |
<title>dummy</title> | |
<link rel="related" type="text/html" href="#{entry.url}" /> | |
<summary type="text/plain">#{entry.comment}</summary> | |
</entry> | |
""" | |
request | |
url: 'http://b.hatena.ne.jp/atom/post' | |
headers: | |
'X-WSSE': wsseHeader 'naoya', 'password' | |
method: 'POST' | |
body: xml | |
, callback | |
HatenaBookmark.user = id: "naoya", password: "hogehoge" | |
HatenaBookmark.post url: 'http://b.hatena.ne.jp/naoya/#atompost', comment: "This is it", (error, response, body) -> | |
console.log body |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment