thanhvg / emacs-reddigg

Browse reddit in emacs org-mode.
GNU General Public License v3.0
43 stars 6 forks source link

http error 403 #11

Open mgudemann opened 1 month ago

mgudemann commented 1 month ago

I get 403 on all subreddits. Initially I though it was that the old.reddit... URLs are not accessible anymore, but copy/pasting for example https://old.reddit.com/r/popular.json?count=25 into the browser does work. I tried changing the User-Agent but that did not help. Any ideas?

thanhvg commented 1 month ago

It looks like reddit wants to charge emacs for free content.

Can you eval this function and try again?


(defun reddigg--promise-json (url)
  "Promise a json from URL."
  (promise-new
   (lambda (resolve reject)
     (url-retrieve (url-encode-url url)
                   (lambda (status)
                     (if (plist-get status :error)
                         (funcall reject (plist-get status :error))
                       (condition-case ex
                           (with-current-buffer (current-buffer)
                             (if (not (url-http-parse-headers))
                                 (funcall reject (buffer-string))
                               (goto-char url-http-end-of-headers)  ; Move to the end of headers
                               (funcall resolve (reddigg--parse-json-buffer))))
                         (error (funcall reject ex)))))))))
mgudemann commented 1 month ago

hi @thanhvg this works without problems, thanks