forked from codingjester/tumblr_client
-
Notifications
You must be signed in to change notification settings - Fork 86
Getting and Answering Asks
Alexander Lozada edited this page Sep 14, 2016
·
2 revisions
Tumblr provides a way for blogs to "ask" each other questions which the receiving blog can publish. the tumblr_client
library allows for easy access to messages and responses.
Tumblr treats messages like unpublished or draft posts. They are published by finding the id
of the submission, and editing the state
to published
.
# assuming we have already authenticated
client = Tumblr::Client.new
# get an array of submissions
submissions = client.submissions("myblogname")
# we want to target the `posts` in our received hash.
submissions = submissions['posts']
# now that we have an array of submissions, we can loop through them
submissions.each do |sub|
client.edit(
"myblogname",
id: sub['id'],
state: 'published'
answer: 'I am replying to this ask!')
end
Note: asks published in this method will always be public. The endpoint for responding to an ask privately is currently undocumented.