首页 > 解决方案 > Rakismet - “空的“博客”价值”

问题描述

我正在尝试使用 httparty调用评论检查"Empty \"blog\" value",即使我在请求中传递了博客参数,我也会收到错误消息。下面是代码

url = "https://my_akistmet_key.rest.akismet.com/1.1/comment-check"

payload = {
           :blog => "http://mysitename.com", 
           :comment_author => "Some Random User Name", 
           :comment_author_email => 'example_1@gmail.com',
           :comment_content=> "Any comment",
           :user_ip=> "A Valid user ip",
           :user_agent=> "A Valid User agent",
           :peramlink=> "A valid peramlink",
           :comment_type=> 'comment'
          }
response = HTTParty.post(url,
                        :body => payload.to_json, 
                        :headers => { 'Content-Type' => 'application/x-www-form-urlencoded'} 
                        )

回复

#<HTTParty::Response:0x55db6da493d8 parsed_response="Missing required field: blog.", @response=#<Net::HTTPOK 200 OK readbody=true>, @headers={"server"=>["nginx"], "date"=>["Wed, 16 Dec 2020 06:20:37 GMT"], "content-type"=>["text/plain; charset=utf-8"], "content-length"=>["29"], "connection"=>["close"], "x-akismet-debug-help"=>["Empty \"blog\" value"]}>


response.body
=> "Missing required field: blog."

标签: ruby-on-railsrubyakismet

解决方案


推荐阅读