Skip to content

Instantly share code, notes, and snippets.

@flanker
Created November 30, 2017 06:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save flanker/29fd57a796c4b8c21b4162b286e224c2 to your computer and use it in GitHub Desktop.
Save flanker/29fd57a796c4b8c21b4162b286e224c2 to your computer and use it in GitHub Desktop.
Create entry using jinshuju.com v1 API
# example ruby code to create entry using jinshuju.com v1 api
# help document for the api: https://help.jinshuju.net/articles/entry-api
require 'net/http'
require 'openssl'
subdomain = 'im' # your jinshuju.com subdomain
form_token = 'A1B2C3' # your form token
key = 'A9f5kBbFRf71wpJvcaiwkC' # your API Key
secret = 'Ch6_XmbaaBr-ResDh0Ga9w' # your API Secret
uri = URI("https://#{subdomain}.jinshuju.com/api/v1/forms/#{form_token}")
payload = "{\"field_1\": \"Anna\", \"field_2\": \"13888888888\"}" # should be a string of valid json
Net::HTTP.start(uri.host, uri.port, use_ssl: true, verify_mode: OpenSSL::SSL::VERIFY_NONE) do |http|
request = Net::HTTP::Post.new uri.request_uri
request.basic_auth key, secret
request.add_field('Content-Type', 'application/json')
request.add_field('Accept', 'application/json')
request.body = payload
response = http.request request
puts response
puts response.body
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment