Comments (13)
@Macman1234 I may have a slight improvement on your solution for answering questions: instead of adding 'answer' to the list of valid options for all post types, what about adding
elif post_type == 'answer': valid += ['answer']
near the bottom of _post_valid_options() where all the other if statements are, and then answer asks using
client.edit_post('[blog name]', id=[ask ID], type='answer', answer=[answer], state='published')
(note the inclusion of a 'type' arg)?
from pytumblr.
The method _post_valid_options
doesn't have any valid options for answer posts (see https://github.com/tumblr/pytumblr/blob/master/pytumblr/__init__.py#L469). Last time I tried working on this (which admittedly was a while ago), I thought it was more complicated than simply adding an if-statement to this one method... if I have time this weekend, I'll see if I can dig up what I did to get answer support. IIRC, though, it was fairly kludgey, which is why I opened an issue instead of making a pull request.
from pytumblr.
Sorry about not responding earlier, but I got that to work simply by changing
valid = ['type', 'state', 'tags', 'tweet', 'date', 'format', 'slug']
to
valid = ['type', 'state', 'tags', 'tweet', 'date', 'format', 'slug', 'answer']
then used
asklist = client.submission('[my blog's name]')
for ask in asklist['posts']:
if ask['type'] == 'answer':
if ask['state'] == 'submission':
client.edit_post('[my blog's name]', id=ask['id'], answer=[whatever I want my bot to answer to any given ask], state='published');
to answer every ask that hasn't yet been answered.
sorry if that was weirdly ambiguous with the brackets.
from pytumblr.
Do you mean creating answers to questions asked? If so, the way to do that through the tumblr API is to, through editing it, setting the "answer" tag to whatever you want to answer (which requires the changing of the valid parameters in the code), and setting the state from "submission" to "published"
from pytumblr.
However, if you mean submitting answer posts to other blogs using pytumblr, I have no idea whether that is possible or how to do that if it is.
from pytumblr.
@sintelligentdesign That looks great to me. Have you done any testing with that solution?
from pytumblr.
I've been using it in one of my projects and it's been working reliably. That said, I haven't written any tests for it. It's a minor change but that's still probably important (I'm just garbage at writing tests).
from pytumblr.
@sintelligentdesign That's almost certainly a better way of implementing that then the way that I've been using: a lot more sane to prevent using "answer" in editing other types of posts. Thanks for that, I'll probably switch over to using it that way.
from pytumblr.
For answering the ask, is there a way to use an image with it?
from pytumblr.
You can include an HTML <img>
element in your answer field, which appears to work on desktop (but not mobile?), unless the post is set to a draft before being published, in which case the image seems to disappear (??). I can try to see if I can figure out something better (read: reliable) sometime this week.
from pytumblr.
Cool
from pytumblr.
Any luck for images? I know that when i answer one it auto uploads it. I was hoping not to host the images and let tumbrl handle them like i have been with answers.
from pytumblr.
By "when I answer one it auto uploads it," are you talking about using the website and answering questions with images manually, or using the API? I assume the first but i just wanted to be sure.
According to the API docs, answer posts don't support the data field used in image posts, and when I gave editing an answer post by adding a data field a shot, it didn't return an error but it didn't work either.
One possibility, although you mentioned wanting to avoid hosting images outside of Tumblr, could be to use an image hosting service's API (I initially was going to suggest Imgur but when I looked the Imgur Python API was deprecated, bummer) and adding the link to the image in the answer field of the answer post. That still has the issue though of apparently not working on mobile (Maybe? Can anybody else test this? Maybe I'm just doing something wrong and dumb. I haven't tried Markdown as the post format but I can't imagine it would make a difference).
from pytumblr.
Related Issues (20)
- How do I get pytumblr into my project and get it running? HOT 2
- Adding source_url to a new post HOT 2
- Proposing a PR to fix a few small typos
- Scheduling posts
- source_url not added as a valid parameter
- How to send and receive tumblr messages via apis HOT 1
- API returns older posts than requested
- Upload v0.1.1 to pypi? HOT 1
- No way of returning all notes?
- Neue Post Format, post type filters, and content HOT 1
- Support for type hints? HOT 1
- Mention some requirements in interactive_console.py
- 'tags' problem HOT 1
- TypeError: expected str, bytes or os.PathLike object, not BufferedReader HOT 1
- Get keys for local application HOT 2
- May I know what need to input for the default callback in order to use this lib locally? HOT 1
- .tagged Method Returning Random Posts
- 'page_number' and 'tumblelog' missing in official docs and in 'posts' function
- poll support?
- `ValueError: Only unicode objects are escapable` on client.info() HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from pytumblr.