adamwynne / twitter-api Goto Github PK
View Code? Open in Web Editor NEWAsync io interface to all the twitter APIs
Async io interface to all the twitter APIs
Currently I am trying to filter a sequence of hashtags. (def response (user-stream :oatuh-creds ...)) does not seem to be the answer. Could you please provide an example where you're filtering on a hashtag and doing something when that hashtag appears in the stream?
trying to run this in lighttable and i'm getting an error saying that it requires a newer version of clojure.
does this library have code that isn't compatible with newer versions of clojure?
Ran 48 tests containing 102 assertions.
3 failures, 37 errors.
Tests failed.
a lot of the errors are
actual: java.lang.Exception: Twitter responded to request with error 215: Bad Authentication data
however, i think i put in the correct creds, as the rest of the tests worked. do only 40 tests require creds?
I was just testing this library out, and ran this code (secrets removed):
(def tehgeekmeisters_creds (make-oauth-creds ...))
(def print_my_toots
"prints tehgeekmeister's toots"
(pprint (statuses-home-timeline :oauth-creds tehgeekmeisters_creds)))
And then this is interspersed in the output on every run so far. Since there's no filenames in this library mentioned, and I'm new to clojure, I can't be of much more help unfortunately.
:java.lang.NullPointerException
at clojure.lang.Var.invoke(Var.java:411)
at user$eval5$fn__7.invoke(form-init5319499649707338122.clj:1)
at user$eval5.invoke(form-init5319499649707338122.clj:1)
at clojure.lang.Compiler.eval(Compiler.java:6619)
at clojure.lang.Compiler.eval(Compiler.java:6609)
at clojure.lang.Compiler.load(Compiler.java:7064)
at clojure.lang.Compiler.loadFile(Compiler.java:7020)
at clojure.main$load_script.invoke(main.clj:294)
at clojure.main$init_opt.invoke(main.clj:299)
at clojure.main$initialize.invoke(main.clj:327)
at clojure.main$null_opt.invoke(main.clj:362)
at clojure.main$main.doInvoke(main.clj:440)
at clojure.lang.RestFn.invoke(RestFn.java:421)
Hi,
Just thought this might be helpful to you -- I ran kibit through the latest code and got 2 warnings:
At /Users/seymores/work/github/twitter-api/src/twitter/callbacks/handlers.clj:60:
Consider using:
(str baos)
instead of:
(.toString baos)
At /Users/seymores/work/github/twitter-api/src/twitter/utils.clj:43:
Consider using:
(pos? (count result))
instead of:
(> (count result) 0)
Dear,
I've been playing around with the twitter-api, and most things seem to work fine, so that is great!
One thing I was not able to figure out so far is how to use 'update-status'. Following your examples, here is what I tried:
...
(def ^:dynamic _creds_ (make-oauth-creds app-consumer-key app-consumer-secret user-access-token user-access-token-secret))
;; => _creds_
(-> (show-user :oauth-creds creds :params {:screen-name "JoachimDeBeule"}) :body :status :text)
;; => "hello world"
(update-status :oauth-creds creds :body [(status-body-part "Hello World from Clojure!")])
;; => exception thrown
The second form returns my current status ("hello world"), so it works, but the last form throws an exception and reports that "Twitter responded to request with error 32: Could not authenticate you"
Could you tell me what I am doing wrong? Both clojure and twitter are new to me, so forgive me if this is a stupid question.
Joachim.
PS: I think I found a small mistake in the RESTful calls example, should it not be "response-throw-error" instead of "response-error-throw"?
Turns out there's a very old 1.0.0 which was published to clojars.org back on 2011-06-30. Luckily, Clojars only shows the chronologically latest versions on the project page and the very latest in the Leiningen/Boot/Gradle/Maven snippets, but still, this is confusing!
I only noticed when lein ancient
told me [twitter-api "1.0.0"]
was available; hopefully other people haven't run into the same issue.
Hello, does twitter-api library support cursors or are you going to implement them?
https://dev.twitter.com/docs/misc/cursoring
Thanks
Matteo
Hi Adam,
is there any way to close a stream when connected to it? The application I'm using your library in makes use of Stuart Sierras Components and Reloaded libs which, for hot reloads in the dev env, means I need to be able to close an existing stream.
Any help would be greatly appreciated!
Thanks
Gary
Calling make-oauth-creds
with the first supported arity, that is with app-key and app-secret only, will leave open files. The offending function is request-app-only-token
, with further calls to execute-request-callbacks
and callbacks-sync-single-default
. This smells like threads are left waiting for I/O somewhere down the stack instead of being shut down.
twitter-api/src/twitter/oauth.clj
Line 50 in 070063f
The leak can be substantial when calling make-oauth-creds
often under that arity.
sudo ls -l /proc/<pid>/fd | wc -l
The README.md includes an example that doesn't use authentication. This is no longer supported on Twitter API 1.1, and leads to: error 215: Bad Authentication data
Thanks for the API!
I'm calling this (list-followers :oauth-creds creds :params {:screen-name username :cursor -1}) and getting
CompilerException java.lang.RuntimeException: Unable to resolve symbol: list-followers in this context, compiling:(...)
Same thing for list-followers.
when call callback, the payload is part of a tweet
I have created a very simple piece of code, pretty much following the example
(def my-creds (twauth/make-oauth-creds oauth-consumer
oauth-consumer-secret
oauth-token
oauth-token-secret))
(defn -main
"I don't do a whole lot ... yet."
[& args]
(println "Hello, World!")
(println (twapi/users-show :oauth-creds my-creds :params {:screen-name "AdamJWynne"}))
(println "wat")
)
Sure enough it works until printing the output of users-show. Then emits the expected "wat" ... and then there is silence, the application won't exit. If i comment the users-show out - the application does a clean shutdown. Is there some kind of magic hook that i have to pull? Looks like something is left hanging and jvm figures there is some thread around doing important work still.
I presume that the org.clojars.adamwynne/clj-oauth
dependency is temporary (as opposed to a fork that aims to be maintained over the long haul), based on the org.clojars.*
groupId. Are there plans to get its changes merged upstream to mattrepl/clj-oauth?
Background: I'd like to build a Friend workflow using clj-oauth, but be able to use twitter-api within the same application, without the dependency conflict that would arise given the current use of org.clojars.adamwynne/clj-oauth
.
Thanks!
Always exactly after 60 secs.
Method used is statuses-filter but should happen with any method using an AsyncStreamingCallback
Specifying a timeout of more than 60 secs also crashes the JVM
Specifying a timeout of less than 60 secs returns a proper exception and does not crash the jvm
Is there a connection, idleConnection timeout not set ? I tried to edit the default client so that it has longer timeouts but with no luck.
I edited this in core.clj, recompiled and run my code but same JVM crash happened...
(defn default-client
"makes a default async client for the http comms"
[]
(memo-create-client :follow-redirects false :connection-timeout 120000 :idle-in-pool-timeout 120000 :request-timeout -1))
SyncStreamingCallback works well...
Hi Adam,
I'm trying to use account-update-profile-banner
:
(account-update-profile-banner :oauth-creds my-twitter-user-creds :params {:banner base64-banner})
where
base64-banner
is a base64 encoded JPEG file.
I have the pretty same code running for account-update-profile-image
which runs without any difficulties. (Parameter is called differently. "image" instead of "banner".)
The banner image is updated actually on Twitter but above mentioned function call results in following exception:
No matching clause:
In case you want to try out the function for yourself you might want to use following helper function for encoding a JPEG file:
(ns twitter-me.core
(:require
[me.raynes.fs :as fs]
[clojure.data.codec.base64 :as b64]
[clojure.java.io :as io]))
(defn encode-jpeg-file [file-name]
(with-open [in (io/input-stream (io/file file-name))]
(let [buf (byte-array (fs/size file-name))
n (.read in buf)]
(apply str (map char (b64/encode buf))))))
I assume it has something to do with the callback handling but I couldn't find it in the code. I assume a cond
is causing the issue.
Kind regards,
Hans-J.
java.io.FileNotFoundException: Could not locate twitter/oauth__init.class or twitter/oauth.clj on classpath:
Happens using Clojure 1.4 and 1.3 and while using twitter-api version 0.6.13. Any idea what the problem is
Project deps looks like
:dependencies [[org.clojure/clojure "1.3.0"]
[compojure "1.1.3"]
[twitter-api "0.6.13"]]
:plugins [[lein-ring "0.7.5"]]
:ring {:handler trend-analyser.handler/app}
:profiles
{:dev {:dependencies [[ring-mock "0.1.3"]]}})
And the individual namespace's deps looks like
(ns trend-analyser.handler
(:use [compojure.core]
[twitter.oauth :as auth]
[twitter.callbacks]
[twitter.callbacks.handlers]
[twitter.api.restful])
(:require [compojure.handler :as handler]
[compojure.route :as route])
(:import
(twitter.callbacks.protocols SyncSingleCallback)))
When I load the follow namespace into my REPL:
(ns yournamespace.core
(:use [twitter.oauth]
[twitter.callbacks]
[twitter.callbacks.handlers]
[twitter.api.restful])
(:import [twitter.callbacks.protocols SyncSingleCallback]))
I receive the following output in my console swank session:
$ lein swank
Connection opened on localhost port 4005.
SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
SLF4J: Defaulting to no-operation (NOP) logger implementation
SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.
is it possible to use this library behind a proxy? wheer/how can I set it?
can this library/funcion library manage the parameter "cursor" in order to retreive more then 5000 followers?
thanks in advance
Hi,
I found test of users-suggestions-slug and users-suggestions-slug-members failed. Sorry, I don't know how to fix this problem.
% lein test
SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
SLF4J: Defaulting to no-operation (NOP) logger implementation
SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.
lein test twitter.api.test.restful
ERROR in (test-user) (NativeConstructorAccessorImpl.java:-2)
expected: (clojure.core/= (clojure.core/get-in (users-suggestions-slug :oauth-creds (twitter.test.creds/make-test-creds) :params {:slug "sports"}) [:status :code]) 200)
actual: java.lang.Exception: Twitter responded to request with error 34: Sorry, that page does not exist
at sun.reflect.NativeConstructorAccessorImpl.newInstance0 (NativeConstructorAccessorImpl.java:-2)
sun.reflect.NativeConstructorAccessorImpl.newInstance (NativeConstructorAccessorImpl.java:39)
sun.reflect.DelegatingConstructorAccessorImpl.newInstance (DelegatingConstructorAccessorImpl.java:27)
java.lang.reflect.Constructor.newInstance (Constructor.java:513)
clojure.lang.Reflector.invokeConstructor (Reflector.java:180)
twitter.callbacks.handlers$response_throw_error.invoke (handlers.clj:52)
twitter.callbacks.handlers$handle_response.doInvoke (handlers.clj:115)
clojure.lang.RestFn.invoke (RestFn.java:464)
twitter.request$get_response_transform$fn__1350.invoke (request.clj:29)
twitter.request$execute_request_callbacks.invoke (request.clj:45)
twitter.core$http_request.invoke (core.clj:103)
twitter.api.restful$users_suggestions_slug.doInvoke (restful.clj:76)
clojure.lang.RestFn.invoke (RestFn.java:457)
twitter.api.test.restful$fn__2404$fn__2417.invoke (restful.clj:51)
twitter.api.test.restful/fn (restful.clj:51)
clojure.test$test_var$fn__6926.invoke (test.clj:701)
clojure.test$test_var.invoke (test.clj:701)
clojure.test$test_all_vars$fn__6930$fn__6937.invoke (test.clj:717)
clojure.test$default_fixture.invoke (test.clj:671)
clojure.test$test_all_vars$fn__6930.invoke (test.clj:717)
clojure.test$default_fixture.invoke (test.clj:671)
clojure.test$test_all_vars.invoke (test.clj:713)
clojure.test$test_ns.invoke (test.clj:736)
clojure.core$map$fn__4087.invoke (core.clj:2434)
clojure.lang.LazySeq.sval (LazySeq.java:42)
clojure.lang.LazySeq.seq (LazySeq.java:60)
clojure.lang.Cons.next (Cons.java:39)
clojure.lang.RT.boundedLength (RT.java:1633)
clojure.lang.RestFn.applyTo (RestFn.java:130)
clojure.core$apply.invoke (core.clj:603)
clojure.test$run_tests.doInvoke (test.clj:751)
clojure.lang.RestFn.applyTo (RestFn.java:137)
clojure.core$apply.invoke (core.clj:601)
user$eval3071$fn__3074.invoke (NO_SOURCE_FILE:1)
user$eval3071.invoke (NO_SOURCE_FILE:1)
clojure.lang.Compiler.eval (Compiler.java:6511)
clojure.lang.Compiler.eval (Compiler.java:6501)
clojure.lang.Compiler.eval (Compiler.java:6501)
clojure.lang.Compiler.eval (Compiler.java:6477)
clojure.core$eval.invoke (core.clj:2797)
clojure.main$eval_opt.invoke (main.clj:297)
clojure.main$initialize.invoke (main.clj:316)
clojure.main$null_opt.invoke (main.clj:349)
clojure.main$main.doInvoke (main.clj:427)
clojure.lang.RestFn.invoke (RestFn.java:421)
clojure.lang.Var.invoke (Var.java:419)
clojure.lang.AFn.applyToHelper (AFn.java:163)
clojure.lang.Var.applyTo (Var.java:532)
clojure.main.main (main.java:37)
ERROR in (test-user) (NativeConstructorAccessorImpl.java:-2)
expected: (clojure.core/= (clojure.core/get-in (users-suggestions-slug-members :oauth-creds (twitter.test.creds/make-test-creds) :params {:slug "sports"}) [:status :code]) 200)
actual: java.lang.Exception: Twitter responded to request with error 34: Sorry, that page does not exist
at sun.reflect.NativeConstructorAccessorImpl.newInstance0 (NativeConstructorAccessorImpl.java:-2)
sun.reflect.NativeConstructorAccessorImpl.newInstance (NativeConstructorAccessorImpl.java:39)
sun.reflect.DelegatingConstructorAccessorImpl.newInstance (DelegatingConstructorAccessorImpl.java:27)
java.lang.reflect.Constructor.newInstance (Constructor.java:513)
clojure.lang.Reflector.invokeConstructor (Reflector.java:180)
twitter.callbacks.handlers$response_throw_error.invoke (handlers.clj:52)
twitter.callbacks.handlers$handle_response.doInvoke (handlers.clj:115)
clojure.lang.RestFn.invoke (RestFn.java:464)
twitter.request$get_response_transform$fn__1350.invoke (request.clj:29)
twitter.request$execute_request_callbacks.invoke (request.clj:45)
twitter.core$http_request.invoke (core.clj:103)
twitter.api.restful$users_suggestions_slug_members.doInvoke (restful.clj:77)
clojure.lang.RestFn.invoke (RestFn.java:457)
twitter.api.test.restful$fn__2404$fn__2421.invoke (restful.clj:52)
twitter.api.test.restful/fn (restful.clj:52)
clojure.test$test_var$fn__6926.invoke (test.clj:701)
clojure.test$test_var.invoke (test.clj:701)
clojure.test$test_all_vars$fn__6930$fn__6937.invoke (test.clj:717)
clojure.test$default_fixture.invoke (test.clj:671)
clojure.test$test_all_vars$fn__6930.invoke (test.clj:717)
clojure.test$default_fixture.invoke (test.clj:671)
clojure.test$test_all_vars.invoke (test.clj:713)
clojure.test$test_ns.invoke (test.clj:736)
clojure.core$map$fn__4087.invoke (core.clj:2434)
clojure.lang.LazySeq.sval (LazySeq.java:42)
clojure.lang.LazySeq.seq (LazySeq.java:60)
clojure.lang.Cons.next (Cons.java:39)
clojure.lang.RT.boundedLength (RT.java:1633)
clojure.lang.RestFn.applyTo (RestFn.java:130)
clojure.core$apply.invoke (core.clj:603)
clojure.test$run_tests.doInvoke (test.clj:751)
clojure.lang.RestFn.applyTo (RestFn.java:137)
clojure.core$apply.invoke (core.clj:601)
user$eval3071$fn__3074.invoke (NO_SOURCE_FILE:1)
user$eval3071.invoke (NO_SOURCE_FILE:1)
clojure.lang.Compiler.eval (Compiler.java:6511)
clojure.lang.Compiler.eval (Compiler.java:6501)
clojure.lang.Compiler.eval (Compiler.java:6501)
clojure.lang.Compiler.eval (Compiler.java:6477)
clojure.core$eval.invoke (core.clj:2797)
clojure.main$eval_opt.invoke (main.clj:297)
clojure.main$initialize.invoke (main.clj:316)
clojure.main$null_opt.invoke (main.clj:349)
clojure.main$main.doInvoke (main.clj:427)
clojure.lang.RestFn.invoke (RestFn.java:421)
clojure.lang.Var.invoke (Var.java:419)
clojure.lang.AFn.applyToHelper (AFn.java:163)
clojure.lang.Var.applyTo (Var.java:532)
clojure.main.main (main.java:37)
lein test twitter.api.test.search
lein test twitter.api.test.streaming
lein test twitter.test-utils.core
lein test twitter.test.callbacks
lein test twitter.test.core
lein test twitter.test.creds
lein test twitter.test.request
lein test twitter.test.upload
lein test twitter.test.utils
Ran 48 tests containing 112 assertions.
0 failures, 2 errors.
Tests failed.
It seems that when executing the statuses-update-with-media function I get 100% CPU utilisation and the operation doesn't complete. I first noticed this in an app I had, however it seems to also happen in the tests. I'm trying to track down what's happening specifically.
SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
SLF4J: Defaulting to no-operation (NOP) logger implementation
SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.
Hi,
The following program doesn't terminate, and I'm not sure why.
(ns test_twitter.core
(:use [twitter.api.search]))
(defn -main []
(println (search :params {:q "@andrew_jones"}))
(println "HERE"))
It does print the results that I'd expect, and I see "HERE", but control isn't returned to the shell. I have to Ctrl-C to terminate the program. If I remove the line with (search :params ...) in it everything is fine.
I'm using Leiningen to build and run the example. I'm using twitter-api 0.6.4 and Clojure 1.3.0.
Hey, first of all, thank you so much for taking the time to write this code. It's saved me a lot of work.
I'm having some difficulty calling account-update-profile-image. I'm guessing I'm just doing something wrong, and I'd really appreciate some help.
My credentials do work for status updates, and all of the other calls I've tried so I'm assuming they're ok. Twitter says they have read, write and direct message permissions.
Going off the code I see in twitter/request.clj, and the test-image-upload function test/upload.clj, I think it should be something like:
(account-update-profile-image :oauth-creds *my-creds*
:body {:image (File. "profile.jpg")})
I've tried a number of different things with the :body parameter, but I typically get this response from twitter:
Exception Twitter responded to request with error 32: Could not authenticate you sun.reflect.GeneratedConstructorAccessor31.newInstance (:-1)
After I've tried this call, I can still use my-creds to update my status successfully, so I'm a bit confused.
Running examples from the tutorial I've come across a problem:
(users-show :oauth-creds my-creds :params {:screen-name "spbowler"})
...works as expected.
However, executing with the same credentials:
(friendships-show :oauth-creds my-creds :params {:screen-name "spbowler"})
...returns:
java.lang.Exception: Twitter responded to request with error 164: Target user not specified.
Hello,
I upgraded a previous project to 0.7.8 (and Clojure itself to 1.8) to find a problem with HeaderMap
#error {
:cause IllegalName: compile__stub.clj_http.headers.clj-http.headers/HeaderMap
:via
[{:type clojure.lang.Compiler$CompilerException
:message java.lang.NoClassDefFoundError: IllegalName: compile__stub.clj_http.
headers.clj-http.headers/HeaderMap, compiling:(clj_http/headers.clj:105:1)
:at [clojure.lang.Compiler analyzeSeq Compiler.java 6875]}
{:type java.lang.NoClassDefFoundError
:message IllegalName: compile__stub.clj_http.headers.clj-http.headers/HeaderM
ap
:at [java.lang.ClassLoader preDefineClass nil -1]}]
Reverting the change for ordering the header resolved it for me.
Before anything else, great job!! Very helpful indeed, Adam.
Well, I have tried it with several users and no matter what always return 0 statuses (I have tried users which have mentions for sure)
CompilerException java.lang.RuntimeException: Unable to resolve symbol: user in this context
Is that a typo - I cant find "user" in any namespace?
Is there something I can do to convert to using SSL, now that Twitter requires it (as of Jan 14)?
Thank you,
John
Exception Twitter responded to request with error 34: Sorry, that page does not exist
sun.reflect.NativeConstructorAccessorImpl.newInstance0 (NativeConstructorAccessorImpl.java:-2)
sun.reflect.NativeConstructorAccessorImpl.newInstance (NativeConstructorAccessorImpl.java:57)
sun.reflect.DelegatingConstructorAccessorImpl.newInstance (DelegatingConstructorAccessorImpl.java:45)
java.lang.reflect.Constructor.newInstance (Constructor.java:525)
clojure.lang.Reflector.invokeConstructor (Reflector.java:180)
twitter.callbacks.handlers/response-throw-error (handlers.clj:52)
Any plans for supporting statuses/lookup
?
This is a handy one if you've got tweets you want to "hydrate" (as they call it).
Hey Guys,
We're seeing some unexpected behavior when using the search API. Basically we're getting:
ConnectException connection timed out
org.jboss.netty.channel.socket.nio.NioClientSocketPipelineSink$Boss.processConnectTimeout
(NioClientSocketPipelineSink.java:386)
Sometimes it works, but mostly there's just a long delay and then it fails. To reproduce in the REPL:
(use `twitter.api.search)
(search :params {:q "#knitting"})
ConnectException connection timed out
org.jboss.netty.channel.socket.nio.NioClientSocketPipelineSink$Boss.processConnectTimeou
(NioClientSocketPipelineSink.java:386)
We're riding on Clojure 1.4 with twitter-api 0.7.0.
Thanks!
Aaron
Hi,
I can't find support for media upload.
https://dev.twitter.com/rest/reference/post/media/upload
Would you consider a PR?
Thanks!
Daniel
Hello,
I don't understand what should I put in my creds map to make it auth with the bearer token for an app_only auth.
Thanks
not sure how to debug this,
but reproducing the issue seems easy:
create new project with the same example code as in the docs (streaming async) ...
when you run it starts receiving tweets but then it stop, the exception handler does not seem to be called at all ....
the code looks like this
(def ^:dynamic
*custom-streaming-callback*
(AsyncStreamingCallback. (comp println #(str %2))
(comp println response-return-everything)
exception-print))
(defn -main
[]
(statuses-filter :params {:track "Borat"}
:oauth-creds *creds*
:callbacks *custom-streaming-callback*)
)
if i use the 0.6.10 version it seems to keep working, but i had issue reconnecting after the network connection gets interrupted (but that's probably error in my code)....
im testing with clojure 1.4 and the only dependencies specified are clojure and twitter-api
Is there a way to detect when a streaming connection is closed so I can try to re-open it?
Hi, me again.
I've made some progress, but I am stuck again and I am also not sure if I am on the right track.
I wrote some clojure code for launching and shutting down a twitter statusses-filter with given credentials, track-string and handler function as follows:
(defn bodypart-text
[response baos](:text %28json/read-json %28.toString baos%29 true%29))
(def statusses-filter (atom nil))
(defn lounch-statusses-filter
"Launches a twitter statusses-filter and pipes the body-part :text
fields to a handler function."
[credentials track-string handler](if @statusses-filter
%28println)
(reset! statusses-filter
(statuses-filter
:params {:track track-string}
:oauth-creds credentials
:callbacks (AsyncStreamingCallback.
(comp handler bodypart-text)
(comp println response-return-everything)
exception-print)))))
(defn shutdown-statusses-filter [](%28:cancel %28meta @statusses-filter%29%29)
(reset! statusses-filter nil))
Here are my questions:
The reason why I define the atom statusses-filter is because I presume that I need the return value of the statusses-filter for shutting it down, is that correct?
With appropriately initialized creds, I can now print out all tweets about, say, Obama as follows:
(twitter/lounch-statusses-filter +creds+ "Obama" println)
This works fine, but it is not clear to me how to provide another handlers besides println. For instance, I would like to have a handler that packs the incoming tweets in a (lazy) sequence for further handling, so that I can map over them as they come in, e.g. (I'm improvising here):
(defn mappin-handler [fn]
#(map fn (to-seq %)))
(twitter/lounch-statusses-filter +creds+ "Obama" (mapping-handler println))
Does this make sense at all?
Thanks in advance!
Joachim.
In order to upgrate to alpha11
, given the noteworthy new specs on ns
, def
, etc... there is a necessary commit to include in http.async.client
(1.2.0
).
Unfortunately this introduces some new stuff (I see the version supported here is kind of dated) and I receive an error (long):
clojure.lang.ExceptionInfo: java.lang.ClassNotFoundException: com.ning.http.client.Cookie, compiling:(twitter/request.clj:1:1)
data: {:file "/tmp/boot.user6040893150050337721.clj", :line 93}
clojure.lang.Compiler$CompilerException: java.lang.ClassNotFoundException: com.ning.http.client.Cookie, compiling:(twitter/request.clj:1:1)
java.lang.ClassNotFoundException: com.ning.http.client.Cookie
...
twitter.request/eval53254/loading--auto-- request.clj: 1
twitter.request/eval53254/invokeStatic request.clj: 1
twitter.request/eval53254 request.clj: 1
...
clojure.core/load/fn core.clj: 6008
clojure.core/load/invokeStatic core.clj: 6007
clojure.core/load core.clj: 5991
...
clojure.core/load-one/invokeStatic core.clj: 5812
clojure.core/load-one core.clj: 5807
clojure.core/load-lib/fn core.clj: 5852
clojure.core/load-lib/invokeStatic core.clj: 5851
clojure.core/load-lib core.clj: 5832
...
clojure.core/apply/invokeStatic core.clj: 659
clojure.core/load-libs/invokeStatic core.clj: 5889
clojure.core/load-libs core.clj: 5873
...
clojure.core/apply/invokeStatic core.clj: 659
clojure.core/require/invokeStatic core.clj: 5911
clojure.core/require core.clj: 5911
...
twitter.oauth/eval53003/loading--auto-- oauth.clj: 1
twitter.oauth/eval53003/invokeStatic oauth.clj: 1
twitter.oauth/eval53003 oauth.clj: 1
...
clojure.core/load/fn core.clj: 6008
clojure.core/load/invokeStatic core.clj: 6007
clojure.core/load core.clj: 5991
...
clojure.core/load-one/invokeStatic core.clj: 5812
clojure.core/load-one core.clj: 5807
clojure.core/load-lib/fn core.clj: 5852
clojure.core/load-lib/invokeStatic core.clj: 5851
clojure.core/load-lib core.clj: 5832
...
clojure.core/apply/invokeStatic core.clj: 659
clojure.core/load-libs/invokeStatic core.clj: 5889
clojure.core/load-libs core.clj: 5873
...
clojure.core/apply/invokeStatic core.clj: 659
clojure.core/require/invokeStatic core.clj: 5911
clojure.core/require core.clj: 5911
...
twitter-streaming-client.impl/eval52118/loading--auto-- impl.clj: 1
twitter-streaming-client.impl/eval52118/invokeStatic impl.clj: 1
twitter-streaming-client.impl/eval52118 impl.clj: 1
...
clojure.core/load/fn core.clj: 6008
clojure.core/load/invokeStatic core.clj: 6007
clojure.core/load core.clj: 5991
...
clojure.core/load-one/invokeStatic core.clj: 5812
clojure.core/load-one core.clj: 5807
clojure.core/load-lib/fn core.clj: 5852
clojure.core/load-lib/invokeStatic core.clj: 5851
clojure.core/load-lib core.clj: 5832
...
clojure.core/apply/invokeStatic core.clj: 659
clojure.core/load-libs/invokeStatic core.clj: 5889
clojure.core/load-libs core.clj: 5873
...
clojure.core/apply/invokeStatic core.clj: 661
clojure.core/use/invokeStatic core.clj: 5975
clojure.core/use core.clj: 5975
...
twitter-streaming-client.core/eval52110/loading--auto-- core.clj: 1
twitter-streaming-client.core/eval52110/invokeStatic core.clj: 1
twitter-streaming-client.core/eval52110 core.clj: 1
...
clojure.core/load/fn core.clj: 6008
clojure.core/load/invokeStatic core.clj: 6007
clojure.core/load core.clj: 5991
...
clojure.core/load-one/invokeStatic core.clj: 5812
clojure.core/load-one core.clj: 5807
clojure.core/load-lib/fn core.clj: 5852
clojure.core/load-lib/invokeStatic core.clj: 5851
clojure.core/load-lib core.clj: 5832
...
clojure.core/apply/invokeStatic core.clj: 659
clojure.core/load-libs/invokeStatic core.clj: 5889
clojure.core/load-libs core.clj: 5873
...
clojure.core/apply/invokeStatic core.clj: 659
clojure.core/require/invokeStatic core.clj: 5911
clojure.core/require core.clj: 5911
...
booma.integration.twitter/eval52102/loading--auto-- twitter.clj: 1
booma.integration.twitter/eval52102/invokeStatic twitter.clj: 1
booma.integration.twitter/eval52102 twitter.clj: 1
...
clojure.core/load/fn core.clj: 6008
clojure.core/load/invokeStatic core.clj: 6007
clojure.core/load core.clj: 5991
...
clojure.core/load-one/invokeStatic core.clj: 5812
clojure.core/load-one core.clj: 5807
clojure.core/load-lib/fn core.clj: 5852
clojure.core/load-lib/invokeStatic core.clj: 5851
clojure.core/load-lib core.clj: 5832
...
clojure.core/apply/invokeStatic core.clj: 659
clojure.core/load-libs/invokeStatic core.clj: 5889
clojure.core/load-libs core.clj: 5873
...
clojure.core/apply/invokeStatic core.clj: 659
clojure.core/require/invokeStatic core.clj: 5911
clojure.core/require core.clj: 5911
...
booma.provider/eval52096/loading--auto-- provider.clj: 1
booma.provider/eval52096/invokeStatic provider.clj: 1
booma.provider/eval52096 provider.clj: 1
...
clojure.core/load/fn core.clj: 6008
clojure.core/load/invokeStatic core.clj: 6007
clojure.core/load core.clj: 5991
...
clojure.core/load-one/invokeStatic core.clj: 5812
clojure.core/load-one core.clj: 5807
clojure.core/load-lib/fn core.clj: 5852
clojure.core/load-lib/invokeStatic core.clj: 5851
clojure.core/load-lib core.clj: 5832
...
clojure.core/apply/invokeStatic core.clj: 659
clojure.core/load-libs/invokeStatic core.clj: 5889
clojure.core/load-libs core.clj: 5873
...
clojure.core/apply/invokeStatic core.clj: 659
clojure.core/require/invokeStatic core.clj: 5911
clojure.core/require core.clj: 5911
...
booma.real-time-api/eval51250/loading--auto-- real_time_api.clj: 1
booma.real-time-api/eval51250/invokeStatic real_time_api.clj: 1
booma.real-time-api/eval51250 real_time_api.clj: 1
...
clojure.core/load/fn core.clj: 6008
clojure.core/load/invokeStatic core.clj: 6007
clojure.core/load core.clj: 5991
...
clojure.core/load-one/invokeStatic core.clj: 5812
clojure.core/load-one core.clj: 5807
clojure.core/load-lib/fn core.clj: 5852
clojure.core/load-lib/invokeStatic core.clj: 5851
clojure.core/load-lib core.clj: 5832
...
clojure.core/apply/invokeStatic core.clj: 659
clojure.core/load-libs/invokeStatic core.clj: 5889
clojure.core/load-libs core.clj: 5873
...
clojure.core/apply/invokeStatic core.clj: 659
clojure.core/require/invokeStatic core.clj: 5911
clojure.core/require core.clj: 5911
...
dev/eval23372/loading--auto-- dev.clj: 1
dev/eval23372/invokeStatic dev.clj: 1
dev/eval23372 dev.clj: 1
...
clojure.core/load/fn core.clj: 6008
clojure.core/load/invokeStatic core.clj: 6007
clojure.core/load core.clj: 5991
...
clojure.core/load-one/invokeStatic core.clj: 5812
clojure.core/load-one core.clj: 5807
clojure.core/load-lib/fn core.clj: 5852
clojure.core/load-lib/invokeStatic core.clj: 5851
clojure.core/load-lib core.clj: 5832
...
clojure.core/apply/invokeStatic core.clj: 659
clojure.core/load-libs/invokeStatic core.clj: 5889
clojure.core/load-libs core.clj: 5873
...
clojure.core/apply/invokeStatic core.clj: 659
clojure.core/require/invokeStatic core.clj: 5911
clojure.core/require core.clj: 5911
...
pod$eval23368.invokeStatic NO_SOURCE_FILE
pod$eval23368.invoke NO_SOURCE_FILE
...
clojure.core/eval/invokeStatic core.clj: 3187
clojure.core/eval core.clj: 3183
boot.pod/eval-in* pod.clj: 437
...
boot.pod/eval-in* pod.clj: 440
boot/dev-backend/fn/fn boot.clj: 185
boot/dev-backend/fn/fn boot.clj: 181
boot.core/run-tasks core.clj: 938
boot.core/boot/fn core.clj: 948
clojure.core/binding-conveyor-fn/fn core.clj: 2019
...
I am not familiar with the code base, but maybe with some hint I can have a look at this.
Hi Adam,
Great library, thank you very much!
I am having an issue where the received tweet stream is incomplete. In some cases, the stream is properly JSON parsed though. Here is the code that I use
(defn parse-tweet
[resp tweet]
(try
(let [tw-obj (parse-string tweet true)]
(when (:text tw-obj)
(log/info (select-keys tw-obj [:id :text]))))
(catch Throwable t
(log/error (.getMessage t) (format "Can't parse tweet\n%s" tweet)))))
(defn vacuum-twttr [tracking]
(statuses-filter :params {:track tracking}
:oauth-creds my-creds
:callbacks (AsyncStreamingCallback.
(fn [resp tweet]
(parse-tweet resp (str tweet)))
(comp println response-return-everything)
exception-print)))
My assumption is that somehow using str
over ByteArrayOutputStream
creates the problem. Do you have any suggestions ?
Thanks a lot,
Bahadir
_EDITED TO ADD_*:
I don't think this is only confined to high-volume streams. Seeing the same issue with an extremely low-volume user stream :(
When following a high-volume stream, I'm seeing a lot of responses being chunked incorrectly. Here's a reproduction case:
(defn bodypart-print-2
[response baos]
(println (str "#### (" (.size baos) ") " (.toString baos))))
(def ^:dynamic
*custom-streaming-callback*
(SyncStreamingCallback. bodypart-print-2
(comp println response-return-everything)
exception-print))
(statuses-filter :params {:track "bieber", :delimited "length"}
:oauth-creds my-creds
:callbacks *custom-streaming-callback*)
I turned on the delimited param to compare the length of the returned chunk to the expected length of the response. That seems like a route to fixing it but I'm reallll new to Clojure so I'm not totally sure where to start.
I'm using code straight from the streaming examples, except I'm filtering on a particular user (oath code not shown):
(def ^:dynamic *custom-streaming-callback*
(AsyncStreamingCallback. (comp println #(:text %) json/read-json #(str %2))
(comp println response-return-everything)
exception-print))
(defn start-filtering []
(statuses-filter :params {:follow 12345}
:oauth-creds *creds*
:callbacks *custom-streaming-callback*))
When I call the start-filtering method all goes well initially, but if the stream is inactive for a bit (around 30 seconds), i.e. no tweets about this particular user are coming down the pike, the following error occurs:
#<EOFException java.io.EOFException: JSON error (end-of-file)>
I assumed that twitter would keep the stream open indefinitely. I'm looking through the twitter-api code to see what I'm missing, but I thought I'd post here to see if anyone else has seen this exception before.
Read me currently has [twitter-api "0.7.7"] should be [twitter-api "0.7.8"].
I'm attempt to call (statuses-user-timeline ...)
(statuses-user-timeline :oath-creds <result of make-oath-creds> :params {:screen-name <username>}))
Which yields
Exception Twitter responded to request with error 215: Bad Authentication data sun.reflect.NativeConstructorAccessorImpl.newInstance0 (NativeConstructorAccessorImpl.java:-2)
java.lang.Exception: Twitter responded to request with error 215: Bad Authentication data
(Unknown Source) sun.reflect.NativeConstructorAccessorImpl.newInstance0
NativeConstructorAccessorImpl.java:62 sun.reflect.NativeConstructorAccessorImpl.newInstance
DelegatingConstructorAccessorImpl.java:45 sun.reflect.DelegatingConstructorAccessorImpl.newInstance
Constructor.java:408 java.lang.reflect.Constructor.newInstance
Reflector.java:180 clojure.lang.Reflector.invokeConstructor
handlers.clj:52 twitter.callbacks.handlers/response-throw-error
handlers.clj:130 twitter.callbacks.handlers/handle-response
RestFn.java:464 clojure.lang.RestFn.invoke
request.clj:29 twitter.request/get-response-transform[fn]
request.clj:45 twitter.request/execute-request-callbacks
core.clj:105 twitter.core/http-request
restful.clj:48 twitter.api.restful/statuses-user-timeline
I was wondering if you were able to succeed with such a call?
Calling restful/oauth-request-token returns:
Exception Twitter responded to request with error 34: Sorry, that page does not exist sun.reflect.NativeConstructorAccessorImpl.newInstance0 (NativeConstructorAccessorImpl.java:-2)
I believe that appending .json to the URL is breaking it.
I've been streaming APIs with twitter-api 0.7.4 for the last few months and up until 2 days ago, it has been working fine.
Since then, all I get is HTTP 401 unauthorised for all my accounts even though I haven't changed anything. Here is some sample output
Problem accessing '/1.1/statuses/filter.json'. Reason:
Unauthorized
and
Problem accessing '/2/user.json'. Reason:
Unauthorized
I'm using oauth authentication, similar to the example code in the Readme. I'm still using the same keys as before, and they're the same keys listed when I check dev.twitter.com
Hi,
I'm trying to fetch all the mentions of a single user and print them as they come in.
I tried changing the example on the front page, but I don't seem to get in any tweets in while i did tweet to/from that account. Can you help me out with this?
Thank you.
(statuses-filter :params {:screen-name "my screen name"}
:oauth-creds creds
:callbacks custom-streaming-callback)
(statuses-filter :params {:follow "myid"}
:oauth-creds creds
:callbacks custom-streaming-callback)
We have a project that depends on both twitter-api and congomongo. The latest congomongo relies on data.json 0.2.0, which introduced breaking changes to the API. Because of this, right now we can't upgrade both twitter-api and congomongo.
Could you please update twitter-api to use data.json 0.2.1? That version includes compatibility shims for 0.1.x functions, and should work as a drop-in replacement for 0.1.3.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.