File tree Expand file tree Collapse file tree 1 file changed +43
-0
lines changed Expand file tree Collapse file tree 1 file changed +43
-0
lines changed Original file line number Diff line number Diff line change
1
+ ==== Send a Twitter Status Update
2
+ // By Tobias Bayer (codebrickie)
3
+
4
+ ===== Problem
5
+
6
+ You want to send a status update to Twitter on behalf of a Twitter user.
7
+
8
+ ===== Solution
9
+
10
+ There is a wrapper for the Twitter API based on http.async.client.
11
+
12
+ Include the wrapper in your project file:
13
+
14
+ .project.clj
15
+ [source,clojure]
16
+ ----
17
+ (defproject twitter "1.0.0-SNAPSHOT"
18
+ :dependencies [[twitter-api "0.7.4"]])
19
+ ----
20
+
21
+ This recipe assumes you have already retrieved an OAuth consumer key and secret for your app from Twitter and an access token and secret for the user.
22
+ SEE RECIPE XYZ ON HOW TO RETRIEVE AN ACCESS TOKEN VIA OAUTH.
23
+
24
+ Define your keys and secrets and send the status update request to Twitter:
25
+
26
+ [source,clojure]
27
+ ----
28
+ (use '[twitter.oauth] '[twitter.api.restful])
29
+
30
+ (def credentials (make-oauth-creds
31
+ "Hux2MTu8gObgzbqNCpPZ2K" ; consumer key
32
+ "hg4GsABTR3asRRjQGtpnHEhkQGaw0JETG3B7lEbd9M" ; consumer secret
33
+ "18407745-cbJHihjBIE0ak6CrQ29631gfwPzm9AhekpGNYtOY4" ; access token
34
+ "mncHyc4g1MGKDHMbI2rrhktRTlgLDXmIG2k1800yIY")) ; access token secret
35
+
36
+ (statuses-update :oauth-creds credentials :params {:status "Hi there, I am sending this tweet from Clojure!"})
37
+ ----
38
+
39
+
40
+ ===== Discussion
41
+
42
+ ===== See Also
43
+ See the https://github.com/adamwynne/twitter-apitwitter-api documentation] for more details.
You can’t perform that action at this time.
0 commit comments