chbrown / twttr

Twitter API client for Clojure supporting REST and Streaming endpoints
35 stars 11 forks source link

README example error #10

Closed emmy0x1 closed 4 years ago

emmy0x1 commented 4 years ago

I get the following error when running the example on the README. Both when I run just api/users-show and the file as a whole.

Evaluating file: core.clj
Syntax error (NullPointerException) compiling at (src/..../core.clj:7:1).
null

Evaluation of file core.clj failed: class clojure.lang.Compiler$CompilerException

Here is the code I'm running: https://github.com/ealmz/mute-twitter/blob/master/src/twitter_mute/core.clj

chbrown commented 4 years ago

Hiya! I bet this is a duplicate of #1 which I 'fixed' in 2215e76 but then — my bad — didn't release a new version 😞

I'll do that now; keep an eye out for 3.2.3 on Clojars ... shortly 😉


Edit: Just released https://clojars.org/twttr/versions/3.2.3 👌

emmy0x1 commented 4 years ago

I'm new to Clojure, maybe I'm not loading the env vars correctly. How do you recommend doing it in my setup?

chbrown commented 4 years ago

@ealmz okay so assuming that you're building a standalone (uber)jar like in your README I expect it'd work by doing all the exports prior to calling java:

export CONSUMER_KEY=l4VAFAKEFAKEFAKEpy7R7
export CONSUMER_SECRET=dVnTimJtFAKEFAKEFAKEFAKEFAKEFAKEBVYnO91BR1G
export ACCESS_TOKEN=195648015-OIHb87zuFAKEFAKEFAKEFAKEFAKEFAKEb5aLUMYo
export ACCESS_TOKEN_SECRET=jsVg1HFAKEFAKEFAKEFAKEFAKEFAKE4yfOLC5cXA9fcXr
# and then — in the same shell session! — run your program:
java -jar twitter-mute-0.1.0-standalone.jar

There are other ways to prepare those env vars, like sticking the exports into your ~/.bashrc (or ~/.zshrc or whatever).

Alternatively, if you really wanna live on the edge, just stick the credentials right into your source code and hope that you remember not to commit it 😉 :

(ns twitter-mute.core
  (:require ...
            [twttr.auth :refer [->UserCredentials]]))

(def creds (->UserCredentials "l4VAFAKEFAKEFAKEpy7R7"
                              "dVnTimJtFAKEFAKEFAKEFAKEFAKEFAKEBVYnO91BR1G"
                              "195648015-OIHb87zuFAKEFAKEFAKEFAKEFAKEFAKEb5aLUMYo"
                              "jsVg1HFAKEFAKEFAKEFAKEFAKEFAKE4yfOLC5cXA9fcXr"))

...
emmy0x1 commented 4 years ago

Putting the secrets directly in the code worked, thanks! I do want to find a solution I can git commit.

How would the top solution work with the repl? For example, I put the secrets in my ~/.zshrc and then I sourced the file, and then I 'jacked-in' to the repl. Didn't work.

Thanks again for your help! I really appreciate it.

Side note: I took some bulk actions against the API (muted all users on follow list), but it doesn't reflect my changes on the timeline. If I go to each user, they are muted. Have you noticed changes made with the API are delayed?

chbrown commented 4 years ago

Great!

That depends on your REPL and shell; not really within the scope of using the Twitter API :/ This library uses environment variables in a very simple way, and environment variables are themselves pretty generic/standard stuff, so I bet you'll have more luck getting apropos answers from your REPL library's maintainer rather than here.

P.S. Haven't noticed changes being delayed, but that'd be a question for the Twitter API devs, not really anything special this library is doing / not doing.

emmy0x1 commented 4 years ago

Awesome, it seemed to be something I was doing. Thank you again for your help!