Created
January 6, 2016 08:17
-
-
Save rinsuki/e5f10b90aea95dda0442 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 "rest_client" | |
| require "json" | |
| require "nokogiri" | |
| class Misskey | |
| attr_accessor :cookie,:csrftoken | |
| def initialize(user,pass) | |
| doc = Nokogiri::HTML(res = RestClient.get("https://misskey.xyz/",{:cookies => @cookie})) | |
| @cookie = res.cookies | |
| @csrftoken = doc.css("/html/head/meta[@name='csrf_token']/@content").to_s | |
| p @csrftoken | |
| res= RestClient.post("https://login.misskey.xyz",{ | |
| "screen-name" => user, | |
| :password => pass | |
| },{ | |
| :cookies => @cookie, | |
| "csrf-token" => @csrftoken | |
| }) | |
| "success" | |
| end | |
| def req(endpoint, param = {}) | |
| JSON.parse(RestClient.post( | |
| "https://himasaku.misskey.xyz/" + endpoint, | |
| param, | |
| { | |
| :cookies => @cookie, | |
| "csrf-token" => @csrftoken | |
| } | |
| )) | |
| end | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment