|
|
@@ -3,23 +3,26 @@
|
|
|
(defparameter +vk-api-url+ "https://api.vk.com/method/~A?v=5.34" "VK.com API endpoint")
|
|
|
|
|
|
(defun %vk-api-call (method &optional args)
|
|
|
- (bordeaux-threads:with-timeout (5)
|
|
|
- (let* ((params (loop for (k . v) in args
|
|
|
- when v
|
|
|
- collect (cons
|
|
|
- (princ-to-string k)
|
|
|
- (princ-to-string v))))
|
|
|
- (response (yason:parse
|
|
|
- (flexi-streams:octets-to-string
|
|
|
- (drakma:http-request (format nil +vk-api-url+ method)
|
|
|
- :method :post
|
|
|
- :parameters params
|
|
|
- :external-format-out :utf8)
|
|
|
- :external-format :utf8)
|
|
|
- :object-as :alist)))
|
|
|
- (when (aget "error" response)
|
|
|
- (error (aget "error_msg" (aget "error" response))))
|
|
|
- (aget "response" response))))
|
|
|
+ (handler-case
|
|
|
+ (bordeaux-threads:with-timeout (5)
|
|
|
+ (let* ((params (loop for (k . v) in args
|
|
|
+ when v
|
|
|
+ collect (cons
|
|
|
+ (princ-to-string k)
|
|
|
+ (princ-to-string v))))
|
|
|
+ (response (yason:parse
|
|
|
+ (flexi-streams:octets-to-string
|
|
|
+ (drakma:http-request (format nil +vk-api-url+ method)
|
|
|
+ :method :post
|
|
|
+ :parameters params
|
|
|
+ :external-format-out :utf8)
|
|
|
+ :external-format :utf8)
|
|
|
+ :object-as :alist)))
|
|
|
+ (when (aget "error" response)
|
|
|
+ (error (aget "error_msg" (aget "error" response))))
|
|
|
+ (aget "response" response)))
|
|
|
+ (bordeaux-threads:timeout (e)
|
|
|
+ (error e))))
|
|
|
|
|
|
(defun vk-wall-get (&key owner-id domain offset count filter extended)
|
|
|
(%vk-api-call "wall.get"
|