一直在用Kickbox的api進行電子郵件驗證。我試圖讓程序只在返回的JSON中顯示結果對象。在ruby中訪問第三方API JSON對象
下面的代碼:
require "kickbox"
require 'httparty'
require 'json'
client = Kickbox::Client.new('ac748asdfwef2fbf0e8177786233a6906cd3dcaa')
kickbox = client.kickbox()
response = kickbox.verify("[email protected]")
file = File.read(response)
json = JSON.parse(file)
json['result']
我得到一個錯誤verify.rb:10:read': no implicit conversion of Kickbox::HttpClient::Response into String (TypeError) from verify.rb:10:in
'
下面是一個示例響應:
{
"result":"undeliverable",
"reason":"rejected_email",
"role":false,
"free":false,
"disposable":false,
"accept_all":false,
"did_you_mean":"[email protected]",
"sendex":0,
"email":"[email protected]",
"user":"bill.lumbergh",
"domain":"gamil.com",
"success":true,
"message":null
}
對不起 - 這裏的輸出是什麼? – Anthony