I hope I won't get trashed for this question. This is my first day with Python and all I've done so far is copy pasting and deducing from other snippets of code. I have no experience with code. I'm trying my hardest however this one I can't get past for the past few hours.
I'm currently adjusting an Editorial (iOS app) workflow to fit my needs — namely: posting to my WordPress site, including the ability to choose from a list of all possible post formats (I have "standard" and "link" enabled).
Here is the faulty bit from the relevant Python script:
console.show_activity('Fetching formats...') server = xmlrpclib.ServerProxy(wp_url) format = server.wp.getPostFormats(wp_blogid, wp_username, wp_password, 'post_format') i = 0 for x in format: formats += '\n' + x['name'] + " " + str(i) i = i+1 workflow.set_variable("formats", formats) console.hide_activity()
I'm getting the error: "string indices must be integers, not str"
What is this supposed to do is later show me in a list my available formats. I've done this successfully with
server.wp.getPostFormats(wp_blogid, wp_username, wp_password, 'post_tag') and
server.wp.getTerms(wp_blogid, wp_username, wp_password, 'category')
I know my problem is where the line with the
i starts, I just have no idea how to solve it. I'm assuming by reading other topics that I need to cast, but I'm not even sure what
getPostFormats returns, or how to do that.
Thanks in advance!
Edit: I've now concluded that
server.wp.getPostFormats returns a dictionary, but I have not a slightest idea on how to retrieve only one set of data (either the key or value) of this dictionary. Please help.