• Home
  • History
  • Annotate
Name Date Size #Lines LOC

..03-May-2022-

.gitignoreH A D05-May-2017252 2317

LICENSEH A D05-May-201711 KiB203169

README.mdH A D05-May-20177.4 KiB237185

avatar_response.goH A D05-May-201768 64

base_post.goH A D05-May-2017734 3532

blog.goH A D05-May-2017216 1412

bloginfo_response.goH A D05-May-201766 64

complete_response.goH A D05-May-2017120 96

drafts_response.goH A D05-May-201798 85

followed_blog.goH A D05-May-2017146 108

followers_response.goH A D05-May-201791 75

following_response.goH A D05-May-201799 75

gotumblr.goH A D05-May-201717.6 KiB471248

gotumblr_test.goH A D05-May-201712.4 KiB446331

likes_response.goH A D05-May-2017122 96

meta.goH A D05-May-201772 75

owned_blog.goH A D05-May-2017185 1311

post_types.goH A D05-May-20171 KiB7663

posts_response.goH A D05-May-2017132 107

request.goH A D05-May-20173.5 KiB11791

request_test.goH A D05-May-20172 KiB6754

user.goH A D05-May-2017108 97

userinfo.goH A D05-May-2017186 108

userinfo_response.goH A D05-May-201766 64

README.md

1gotumblr
2========
3
4Description
5-----------
6
7A Go [Tumblr API](http://www.tumblr.com/docs/en/api/v2) v2 Client.
8
9[![GoDoc](https://godoc.org/github.com/MariaTerzieva/gotumblr?status.png)](https://godoc.org/github.com/MariaTerzieva/gotumblr)
10
11Install gotumblr
12----------------
13
14In terminal write `go get github.com/MariaTerzieva/gotumblr`
15
16Running the tests
17-----------------
18
19Run the tests with `go test` to check if everything is ok.
20
21Using the package
22-----------------
23
24To use this package in your projects do this (after install):
25
26`import "github.com/MariaTerzieva/gotumblr"`
27
28You are going to need a consumer key, consumer secret, callback URL, token and token secret.
29You can get the consumer key, consumer secret and callback URL by registering a Tumblr application.
30You can do so by clicking [here](http://www.tumblr.com/oauth/apps).
31The token and token secret you can get by using OAUTH.
32If you want to use this package just for your own tumblr account, after registering the application,
33click on the Explore API option and allow it access to your Tumblr account. You are going to see a tab "Show keys".
34Click on it and you will get your token and token secret but if you want, you can also obtain them using OAUTH.
35
36Examples
37--------
38
39First import the package in your project as shown above.
40
41Then create NewTumblrRestClient with your credentials(consumer key, consumer secret, token, token secret and callback url):
42
43		client := gotumblr.NewTumblrRestClient("consumer_key", "consumer_secret", "token", "token_secret", "callback_url", "http://api.tumblr.com")
44
45Then use the client you just created to get the information you need. Here are some examples with what I got for my account:
46
47		info := client.Info()
48		fmt.Println(info.User.Name)
49		//Output:
50		//mgterzieva
51
52		likes := client.Likes(map[string]string{})
53		fmt.Println(likes.Liked_count)
54		//Output:
55		//63
56
57		following := client.Following(map[string]string{})
58		fmt.Println(following.Total_blogs)
59		//Output:
60		//1
61
62		dashboard := client.Dashboard(map[string]string{"limit": "1"})
63		if len(dashboard.Posts) != 0 {
64			var base_dashboard_post gotumblr.BasePost
65			for i, _ := range dashboard.Posts {
66				json.Unmarshal(dashboard.Posts[i], &base_dashboard_post)
67				fmt.Println(base_dashboard_post.State)
68				//Output:
69				//published
70			}
71		}
72
73		tagged := client.Tagged("golang", map[string]string{"limit": "1"})
74		if len(tagged) != 0 {
75			var base_tagged_post gotumblr.BasePost
76			for i, _ := range tagged {
77				json.Unmarshal(tagged[i], &base_tagged_post)
78				fmt.Println(base_tagged_post.State)
79				//Output:
80				//published
81			}
82		}
83
84		blogname := "mgterzieva.tumblr.com" //this is my blogname. Change this according to your usecase and credentials.
85		blogInfo := client.BlogInfo(blogname)
86		fmt.Println(blogInfo.Blog.Title)
87		//Output:
88		//Maria's blog
89
90		followers := client.Followers(blogname, map[string]string{})
91		fmt.Println(followers.Total_users)
92		//Output:
93		//0
94
95		blog_likes := client.BlogLikes(blogname, map[string]string{})
96		fmt.Println(blog_likes.Liked_count)
97		//Output:
98		//63
99
100		queue := client.Queue(blogname, map[string]string{})
101		fmt.Println(len(queue.Posts))
102		//Output:
103		//0
104
105		drafts := client.Drafts(blogname, map[string]string{})
106		fmt.Println(len(drafts.Posts))
107		//Output:
108		//6
109
110		submission := client.Submission(blogname, map[string]string{})
111		fmt.Println(len(submission.Posts))
112		//Output:
113		//0
114
115		avatar := client.Avatar(blogname, 64)
116		fmt.Println(avatar.Avatar_url)
117		//Output:
118		//http://25.media.tumblr.com/avatar_49f49d0b9209_64.png
119
120		other_blogname := "http://thehungergamesmovie.tumblr.com"
121		follow := client.Follow(other_blogname)
122		fmt.Println(follow)
123		//Output:
124		//<nil>
125
126		unfollow := client.Unfollow(other_blogname)
127		fmt.Println(unfollow)
128		//Output:
129		//<nil>
130
131		id := "72078164824" //this is the id of a post of mine. Change this according to your usecase.
132		//There is an Id field in all of the post object types in this library.
133		reblogKey := "6l3e2pGL" //this is the reblogKey of a post of mine. Change this according to your usecase.
134		//There is a Reblog_key field in all of the post object types in this library.
135		like := client.Like(id, reblogKey)
136		fmt.Println(like)
137		//Output:
138		//<nil>
139
140		unlike := client.Unlike(id, reblogKey)
141		fmt.Println(unlike)
142		//Output:
143		//<nil>
144
145		reblog := client.Reblog(blogname, map[string]string{"id": id, "reblog_key": reblogKey})
146		fmt.Println(reblog)
147		//Output:
148		//<nil>
149
150		state := "draft"
151		textPost := client.CreateText(blogname, map[string]string{"body": "Hello happy world!", "state": state})
152		fmt.Println(textPost)
153		//Output:
154		//<nil>
155
156		quote := "A happy heart makes the face cheerful."
157		source := "Proverbs 15:13"
158		quotePost := client.CreateQuote(blogname, map[string]string{"quote": quote, "source": source, "state": state})
159		fmt.Println(quotePost)
160		//Output:
161		//<nil>
162
163		title := "Follow me on tumblr, guys! :)"
164		url := "http://mgterzieva.tumblr.com"
165		linkPost := client.CreateLink(blogname, map[string]string{"url": url, "title": title, "state": state})
166		fmt.Println(linkPost)
167		//Output:
168		//<nil>
169
170		conversation := "John Doe: Hi there!\nJane Doe: Hi, John!\nJane Doe: ♥♥♥"
171		//separate the tags with commas and don't leave whitespaces around the commas
172		tags := "Saint Valentine's day,14th of February,lots of love,xoxo"
173		chatPost := client.CreateChatPost(blogname, map[string]string{"conversation": conversation, "tags": tags, "state": state})
174		fmt.Println(chatPost)
175		//Output:
176		//<nil>
177
178		text := "Hello happy world!" //if you are editing a text post
179		editPost := client.EditPost(blogname, map[string]string{"id": id, "body": text})
180		fmt.Println(editPost)
181		//Output:
182		//<nil>
183
184		deletePost := client.DeletePost(blogname, id)
185		fmt.Println(deletePost)
186		//Output:
187		//<nil>
188
189		code := `<iframe width="560" height="315" src="//www.youtube.com/embed/uJNvZRAmeqY" frameborder="0" allowfullscreen></iframe>`
190		caption := "<b>Mother knows best</b>"
191		embedVideo := client.CreateVideo(blogname, map[string]string{"embed": code, "state": state, "caption": caption})
192		fmt.Println(embedVideo)
193		//Output:
194		//<nil>
195
196		song := "https://soundcloud.com/tiffany-alvord-song/the-one-that-got-away-cover-by"
197		songPostByURL := client.CreateAudio(blogname, map[string]string{"external_url": song, "state": state})
198		fmt.Println(songPostByURL)
199		//Output:
200		//<nil>
201
202		picture := "http://thumbs.dreamstime.com/z/cute-panda-17976617.jpg"
203		photoPostByURL := client.CreatePhoto(blogname, map[string]string{"source": picture, "state": state})
204		fmt.Println(photoPostByURL)
205		//Output:
206		//<nil>
207
208Further information
209-------------------
210
211If you still don't get how to work with this package don't worry! :)
212Read the [project documentation](https://godoc.org/github.com/MariaTerzieva/gotumblr) or
213the [Tumblr API](http://www.tumblr.com/docs/en/api/v2) or
214write an e-mail at mgterzieva@abv.bg if these don't help. :)
215
216Contribution
217------------
218In case you find any issues with this code, use the project's Issues page to report them or send pull requests.
219
220License
221-------
222
223Copyright 2014 Maria Terzieva
224
225
226Licensed under the Apache License, Version 2.0 (the "License");
227you may not use this file except in compliance with the License.
228You may obtain a copy of the License at
229
230   http://www.apache.org/licenses/LICENSE-2.0
231
232Unless required by applicable law or agreed to in writing, software
233distributed under the License is distributed on an "AS IS" BASIS,
234WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
235See the License for the specific language governing permissions and
236limitations under the License.
237