Created
March 29, 2010 00:19
-
-
Save caironoleto/347171 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'rubygems' | |
require 'active_record' | |
require 'net/http' | |
require 'uri' | |
email = "YOUR_EMAIL_HERE" | |
password = "YOUR_PASSWORD_HERE" | |
ActiveRecord::Base.establish_connection(:adapter => "mysql", :socket => "/tmp/mysql.sock", :user => "root", :password => "root", :database => "YOUR_DATABASE_HERE") | |
results = ActiveRecord::Base.connection.execute("SELECT * FROM `wp_posts` WHERE post_type = 'post' and post_status='publish' order by post_date asc;") | |
results.each do |result| | |
options = { | |
:email => email, | |
:password => password, | |
:type => "text", | |
:title => result[5], | |
:date => result[3], | |
:body => result[4], | |
:generator => "Cairo Noleto" | |
} | |
puts "Upload post #{result[0]}." | |
res = Net::HTTP.post_form(URI.parse('http://www.tumblr.com/api/write'), options) | |
puts "Done. New post ID: #{res.body}" | |
puts "" | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment