Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 7112d5d

Browse files
committed
Add basic twitter status update recipe
1 parent 731065c commit 7112d5d

File tree

1 file changed

+43
-0
lines changed

1 file changed

+43
-0
lines changed
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
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.

0 commit comments

Comments
 (0)