我有以下Emacs Lisp,它构建了对Freebase的查询。如果我将生成的网址复制并粘贴到我的浏览器中或命令行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.
。
你能帮忙吗?
答案 0 :(得分:1)
似乎问题与变量url-request-data
以下代码适用于我
(defun fbquery (type str)
(let ((url-request-method "GET")
(foo (concat "?query=" (url-hexify-string str)
"&filter=" (url-hexify-string type))))
(url-retrieve (concat fb-url foo)
(lambda (status) (switch-to-buffer (current-buffer))))))
请注意,我重命名了该变量(以避免错误)并将其连接到url