Skip to content

Instantly share code, notes, and snippets.

@vabruzzo
Created July 30, 2015 17:43
Show Gist options
  • Select an option

  • Save vabruzzo/bb2c1bf9429d4cfb7353 to your computer and use it in GitHub Desktop.

Select an option

Save vabruzzo/bb2c1bf9429d4cfb7353 to your computer and use it in GitHub Desktop.
#!/usr/local/bin/ruby
# posting to a topic
require('/path/to/discourse_api/gem')
client = DiscourseApi::Client.new("https://push-language.hampshire.edu")
client.api_key = "YOUR_API_KEY"
client.api_username = "slack_archive"
response = client.create_post(
topic_id: 101,
raw: "this is the raw text of a post created using the discourse_api Ruby gem"
)
puts response
################################################################################
#!/usr/local/bin/ruby
# creating a topic
require('/path/to/discourse_api/gem')
client = DiscourseApi::Client.new("https://push-language.hampshire.edu")
client.api_key = "YOUR_API_KEY"
client.api_username = "slack_archive"
response = client.create_topic(
category: "Slack Archives",
skip_validations: true,
auto_track: false,
title: "discourse API test topic",
raw: "this is the text of the tet topic"
)
puts response
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment