Created
April 10, 2016 10:41
-
-
Save s2terminal/4a6d11d90803778e00027d6830e614e7 to your computer and use it in GitHub Desktop.
Azure Machine Learning Web サービス Ruby版コード
This file contains 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
def request_azure_ml(request_uri, twitter_user_id, api_key) | |
uri = URI.parse(request_uri) | |
http = Net::HTTP.new(uri.host, uri.port) | |
http.use_ssl = true | |
http.verify_mode = OpenSSL::SSL::VERIFY_NONE | |
req = Net::HTTP::Post.new(uri.request_uri) | |
req["Content-Type"] = 'application/json' | |
req["Authorization"] = 'Bearer ' + api_key | |
req.body = { | |
"Inputs": { | |
"input1": { | |
"ColumnNames": [ | |
"twitter_user_id" | |
], | |
"Values": [[twitter_user_id]] | |
} | |
}, | |
"GlobalParameters": {} | |
}.to_json | |
res = http.request(req) | |
return JSON.parse(res.body)["Results"]["output1"]["value"]["Values"].flatten[2..-1] | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment