ruby - rails: User Net::Http post json to reply review google app develop api -
i want reply review google app.
this link document: https://developers.google.com/android-publisher/api-ref/reviews/reply
i use net::http post data.
my method reply review
def self.reply_review(package , access_token, review_id, text ) uri = uri("https://www.googleapis.com/androidpublisher/v2/applications/#{package}/reviews/#{review_id}:reply?access_token=#{access_token}") puts "https://www.googleapis.com/androidpublisher/v2/applications/#{package}/reviews/#{review_id}:reply?access_token=#{access_token}" http = net::http.new(uri.host, uri.port) http.use_ssl = true params = { "replytext" => text } request = net::http::post.new( uri.request_uri, 'content-type' => 'application/json' ) request.body = params.to_json response = http.request(request) puts response puts(response.body) response end
but response
=> => #<net::httpbadrequest 400 bad request readbody=true>
i sure data accurate (packagename, access_token, replyid). , how fix reply review use net::http
i have used connect google verification api.
require 'openssl' require 'net/http' uri =uri.parse("https://www.googleapis.com/androidpublisher/v2/applications/#{package}/reviews/#{review_id}:reply?access_token=#{access_token}") http = net::http.new(uri.host, uri.port) http.use_ssl = true http.verify_mode = openssl::ssl::verify_peer request = net::http::post.new(uri.request_uri, initheader = {'content-type' =>'application/json'}) request.form_data = {"replytext" => text} response = http.request(request)
Comments
Post a Comment