You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: network-io/twitter-api/twitter-api.asciidoc
+26-7Lines changed: 26 additions & 7 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,9 +1,9 @@
1
-
==== Send a Twitter Status Update
1
+
==== Using the Twitter API
2
2
// By Tobias Bayer (codebrickie)
3
3
4
4
===== Problem
5
5
6
-
You want to send a status update to Twitter on behalf of a Twitter user.
6
+
You want to connect to Twitter and use its API.
7
7
8
8
===== Solution
9
9
@@ -18,8 +18,7 @@ Include the wrapper in your project file:
18
18
:dependencies [[twitter-api "0.7.4"]])
19
19
----
20
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.
21
+
This recipe assumes you have already retrieved an OAuth footnote:[See the Twitter documentation on how to receive OAuth credentials at https://dev.twitter.com/docs/auth/obtaining-access-tokens] consumer key and secret for your app from Twitter and an access token and secret for the user. Make sure your app has read/write access in order to post status updates.
23
22
24
23
Define your keys and secrets and send the status update request to Twitter:
25
24
@@ -36,12 +35,12 @@ Define your keys and secrets and send the status update request to Twitter:
36
35
(statuses-update :oauth-creds credentials :params {:status "Hi there, I am sending this tweet from Clojure!"})
37
36
;; -> {:status {:code 200, :msg "OK",...
38
37
----
39
-
38
+
40
39
41
40
===== Discussion
42
41
43
-
Twitter-api offers more than just sending status updates.
44
-
The structure of function calls basically remains the same. Twitter-api functions take the credentials and request parameters as arguments.
42
+
++twitter-api++ offers more than just sending status updates.
43
+
The structure of function calls basically remains the same. ++twitter-api++ functions take the credentials and request parameters as arguments.
45
44
46
45
For example, you can show user details with ++users-show++:
47
46
@@ -51,5 +50,25 @@ For example, you can show user details with ++users-show++:
51
50
;; -> ...:id 40514394, :profile_background_image_url_https "https://si0.twimg.com/images/themes/theme1/bg.png", :description "Without being overly modest, you can read this because of me.", :profile_text_color "333333", :screen_name "Alan_M_Turing"...
52
51
----
53
52
53
+
Using Twitter's streaming feature for reading a user's timeline is also possible.
54
+
First you should define a callback function that will be called later every time a new tweet is received:
0 commit comments