1
0

vk.lisp 1.1 KB

12345678910111213141516171819202122232425262728293031
  1. (in-package #:chatikbot)
  2. (defparameter +vk-api-url+ "https://api.vk.com/method/~A?v=5.34" "VK.com API endpoint")
  3. (defun %vk-api-call (method &optional args)
  4. (bordeaux-threads:with-timeout (5)
  5. (let* ((params (loop for (k . v) in args
  6. when v
  7. collect (cons
  8. (princ-to-string k)
  9. (princ-to-string v))))
  10. (response (yason:parse
  11. (flexi-streams:octets-to-string
  12. (drakma:http-request (format nil +vk-api-url+ method)
  13. :method :post
  14. :parameters params
  15. :external-format-out :utf8)
  16. :external-format :utf8)
  17. :object-as :alist)))
  18. (when (aget "error" response)
  19. (error (aget "error_msg" (aget "error" response))))
  20. (aget "response" response))))
  21. (defun vk-wall-get (&key owner-id domain offset count filter extended)
  22. (%vk-api-call "wall.get"
  23. (list (cons "owner_id" owner-id)
  24. (cons "domain" domain)
  25. (cons "offset" offset)
  26. (cons "count" count)
  27. (cons "filter" filter)
  28. (cons "extended" extended))))