我有以下 Emacs Lisp,它建立了对 Freebase 的查询。如果我将它生成的 URL 复制并粘贴到我的浏览器或命令行curl
中,我会得到我期望的结果:
curl -X GET https://www.googleapis.com/freebase/v1/search?query=Oil%20on%20Canvas&filter=(any%20type%3avisual_art%2fvisual_art_medium) ...这行得通。
但我不能让它在 Emacs 中工作:
(require 'url)
(defvar fb-url "https://www.googleapis.com/freebase/v1/search")
(defvar materials-type "(any type:visual_art/visual_art_medium)")
(defun fbquery (type str)
(let ((url-request-method "GET")
(url-request-data (concat "?query=" (url-hexify-string str)
"&filter=" (url-hexify-string type))))
(url-retrieve (concat fb-url)
(lambda (status) (switch-to-buffer (current-buffer))))))
(setq url-debug t)
(fbquery materials-type "Oil on Canvas")
我回来了:
HTTP/1.0 400 Bad Request
... Your client has issued a malformed or illegal request. That's all we know.
.
你能帮我吗?