Skip to content

Instantly share code, notes, and snippets.

@naoya
Created October 15, 2011 06:52
Show Gist options
  • Save naoya/1289178 to your computer and use it in GitHub Desktop.
Save naoya/1289178 to your computer and use it in GitHub Desktop.
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