snoo
snoo copied to clipboard
subreddit_settings uses incorrect parameter
It wants a subreddit name, i.e. "baseball", as the first parameter and assigns it to 'r'. The API wants 'sr' instead, which is a Thing ID such as 't3_12345'.
I've been doing this to get around it:
settings = reddit.get_subreddit_settings("baseball")
sidebar = 'Stuff'
# Notice the empty string as the first parameter, because it doesn't matter
reddit.subreddit_settings("",
:sr => settings["data"]["subreddit_id"], # This is the actual one it uses
:name => settings["data"]["name"],
:title => settings["data"]["title"],
:wikimode => settings["data"]["wikimode"],
:wiki_edit_karma => settings["data"]["wiki_edit_karma"],
:exclude_banned_modqueue => settings["data"]["exclude_banned_modqueue"],
:show_media => settings["data"]["show_media"],
:public_description => settings["data"]["public_description"],
:"header-title" => settings["data"]["header_hover_text"],
:description => sidebar
)
Good catch. Looks like this changed. The gems methodsusually accept anything as a body value and stick it in the request.
I'd you want to make a pull request fixing this, I'll get it in a fixy build soon enough On Apr 10, 2013 12:10 PM, "Steven Hoffman" [email protected] wrote:
It wants a subreddit name, i.e. "baseball", as the first parameter and assigns it to 'r'. The API wants 'sr' instead, which is a Thing ID such as 't3_12345'.
I've been doing this to get around it:
settings = reddit.get_subreddit_settings("baseball") sidebar = 'Stuff'
Notice the empty string as the first parameter, because it doesn't matterreddit.subreddit_settings("",
:sr => settings["data"]["subreddit_id"], # This is the actual one it uses :name => settings["data"]["name"], :title => settings["data"]["title"], :wikimode => settings["data"]["wikimode"], :wiki_edit_karma => settings["data"]["wiki_edit_karma"], :exclude_banned_modqueue => settings["data"]["exclude_banned_modqueue"], :show_media => settings["data"]["show_media"], :public_description => settings["data"]["public_description"], :"header-title" => settings["data"]["header_hover_text"], :description => sidebar)
— Reply to this email directly or view it on GitHubhttps://github.com/paradox460/snoo/issues/7 .
Do you suggest simply change the first parameter from 'subreddit' to 'subreddit_id' and 'r' to 'sr'? This might break previous usage but making 'sr' an optional parameter is most like not enough as most users don't know it is required. Also seems this functions needs a default value for 'title' and 'wikimode'. I'm getting these errors if they are not specified:
{
"json": {
"errors": [
[
"INVALID_OPTION",
"that option is not valid",
"wikimode"
]
]
}
}
and
{
"json": {
"errors": [
[
"NO_TEXT",
"we need something here",
"title"
]
]
}
}
I'll have to look at the api, but I do know it works as of the latest release. The iama sidebar is controlled by a bot using snoo, and the sidebar updates go through this api.