Update Posterous migrator to take an api_token instead of email and pass

The Posterous API call for retrieving a user's API token (`/api/2/auth/token`) is no longer supported and returns 410 GONE. This patch updates the #process method to accept an API token instead of an email address and password. A user's API token can be retrieved from http://posterous.com/api.
This commit is contained in:
Nicholas Firth-McCoy 2012-01-18 10:55:58 +11:00
parent fa6d013791
commit c3b12457a0
1 changed files with 3 additions and 5 deletions

View File

@ -27,12 +27,10 @@ module Jekyll
end
end
def self.process(email, pass, blog = 'primary')
@email, @pass = email, pass
@api_token = JSON.parse(self.fetch("/api/2/auth/token").body)['api_token']
def self.process(api_token, blog = 'primary')
FileUtils.mkdir_p "_posts"
posts = JSON.parse(self.fetch("/api/v2/users/me/sites/#{blog}/posts?api_token=#{@api_token}").body)
posts = JSON.parse(self.fetch("/api/v2/users/me/sites/#{blog}/posts?api_token=#{api_token}").body)
page = 1
while posts.any?
@ -61,7 +59,7 @@ module Jekyll
end
page += 1
posts = JSON.parse(self.fetch("/api/v2/users/me/sites/#{blog}/posts?api_token=#{@api_token}&page=#{page}").body)
posts = JSON.parse(self.fetch("/api/v2/users/me/sites/#{blog}/posts?api_token=#{api_token}&page=#{page}").body)
end
end
end