Skip to content

Instantly share code, notes, and snippets.

@ssig33
Created March 19, 2013 08:45
Show Gist options
  • Select an option

  • Save ssig33/5194579 to your computer and use it in GitHub Desktop.

Select an option

Save ssig33/5194579 to your computer and use it in GitHub Desktop.
Twitter の UserStreams を Fastladder に送りこむ
require 'user-stream-receiver'
require 'json'
require 'rest_client'
HOST = ''
API_KEY = ''
UserStreamReceiver.new.run{|chunk|
begin
chunk = JSON.parse(chunk)
next unless chunk['text']
hash = {
feedlink: "https://twitter.com/#{chunk['user']['screen_name']}",
feedtitle: "Twitter #{chunk['user']['screen_name']}",
link: "https://twitter.com/#{chunk['user']['screen_name']}/status/#{chunk['id']}",
title: "Twitter #{chunk['user']['screen_name']}",
body: chunk['text'],
author: chunk['user']['screen_name'],
category: 'Twitter',
published_date: chunk['created_at']
}
RestClient.post "http://#{HOST}/rpc/update_feed", json: hash.to_json, api_key: API_KEY
rescue
p 'error'
end
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment