aboutsummaryrefslogtreecommitdiff
path: root/contrib/linkding/linkding.rb
blob: d0d59933c310f7422cd309382c0b47b0e598c9e4 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
#!/usr/bin/env ruby

require 'httparty' # gem install httparty
require 'json'

# Set this to your own instance's API URL:
linkding_uri = "http://example.linkding.com/api/bookmarks"

# Get your Linkding API key from Settings > Integrations
# Set the LINKDING_TOKEN env variable with you Linkding key, or just hardcode it here.
token = ENV['LINKDING_TOKEN']

link_url = ARGV[0]
link_title = ARGV[1]
description = ARGV[2]
website_title = ARGV[3]

params = {url: URI(link_url), title: link_title, website_title: website_title, unread: true}
headers = {'Content-Type' => "application/json", 'Authorization' => "Token #{token}"}

resp = HTTParty.post(linkding_uri, body: params.to_json, headers: headers)