require 'json' $access_token = def add_word(word) puts "Checking word : #{word}" begin result = `curl https://api.shanbay.com/bdc/search/?word=#{word}&access_token=#{$access_token}` result = JSON.parse(result) word_id = result['data']['id'] word_learning_id = result['data']['learning_id'] puts " word #{word}; id : #{word_id} ; learning_id: #{word_learning_id}" if(word_learning_id == nil) puts "Add word #{word} into Shanbay" result = `curl -X POST --data "id=#{word_id}" https://api.shanbay.com/bdc/learning/?access_token=#{$access_token}` puts result end rescue Exception => e puts e end end File.open('words.txt','r') do | f| f.each_line do | line| add_word(line) unless line.strip.length < 1 sleep 1 end end