Skip to content

Commit

Permalink
(twittering-http-get): add an optional argument for a response data f…
Browse files Browse the repository at this point in the history
…ormat.

(twittering-http-post): likewise.
  • Loading branch information
yata committed Feb 6, 2010
1 parent 8618298 commit ea6eefd
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 6 deletions.
8 changes: 8 additions & 0 deletions ChangeLog
@@ -1,3 +1,11 @@
2010-02-07 Satoshi Yatagawa <yata_github@y.hauN.org>

* twittering-mode.el (twittering-http-get): Add an optional
argument for a response data format.
(twittering-http-post): Likewise.
(twittering-get-list-index): Adjust callers.
(twittering-http-post): Delete unused argument `contents'.

2010-02-06 Satoshi Yatagawa <yata_github@y.hauN.org>

* twittering-mode.el (twittering-http-default-sentinel): New defun
Expand Down
17 changes: 11 additions & 6 deletions twittering-mode.el
Expand Up @@ -1476,13 +1476,15 @@ Available keywords:
headers
))

(defun twittering-http-get (host method &optional noninteractive parameters sentinel)
(defun twittering-http-get (host method &optional noninteractive parameters format sentinel)
(if (null format)
(setq format "xml"))
(if (null sentinel)
(setq sentinel 'twittering-http-get-default-sentinel))

(twittering-start-http-session
"GET" (twittering-http-application-headers "GET")
host nil (concat "/" method ".xml") parameters noninteractive sentinel))
host nil (concat "/" method "." format) parameters noninteractive sentinel))

(defun twittering-created-at-to-seconds (created-at)
(let ((encoded-time (apply 'encode-time (parse-time-string created-at))))
Expand Down Expand Up @@ -1579,20 +1581,23 @@ Available keywords:
(setq twittering-list-index-retrieved indexes))))
nil))

(defun twittering-http-post (host method &optional parameters contents sentinel)
(defun twittering-http-post (host method &optional parameters format sentinel)
"Send HTTP POST request to twitter.com (or api.twitter.com)
HOST is hostname of remote side, twitter.com or api.twitter.com.
METHOD must be one of Twitter API method classes
(statuses, users or direct_messages).
PARAMETERS is alist of URI parameters.
ex) ((\"mode\" . \"view\") (\"page\" . \"6\")) => <URI>?mode=view&page=6"
ex) ((\"mode\" . \"view\") (\"page\" . \"6\")) => <URI>?mode=view&page=6
FORMAT is a response data format (\"xml\", \"atom\", \"json\")"
(if (null format)
(setq format "xml"))
(if (null sentinel)
(setq sentinel 'twittering-http-post-default-sentinel))

(twittering-start-http-session
"POST" (twittering-http-application-headers "POST")
host nil (concat "/" method ".xml") parameters noninteractive sentinel))
host nil (concat "/" method "." format) parameters noninteractive sentinel))

(defun twittering-http-post-default-sentinel (header proc noninteractive &optional suc-msg)
;; FIXME: we should take a xmltree from current-burrer and parse it
Expand Down Expand Up @@ -2295,7 +2300,7 @@ variable `twittering-status-format'."
(defun twittering-get-list-index (username)
(twittering-http-get "api.twitter.com"
(concat "1/" username "/lists")
t nil
t nil nil
'twittering-http-get-list-index-sentinel))

(defun twittering-get-list-index-sync (username)
Expand Down

0 comments on commit ea6eefd

Please sign in to comment.