Ruby / HTTParty:使用其API将提要添加到Google Reader时超时

|| 我正在尝试使用其API向Google Reader添加订阅,但是出现以下错误:   执行到期 我没有问题(使用\'get \')阅读订阅或标签列表。但是,当我尝试添加子项时(使用\'post \'),它超时 该代码是用Ruby on Rails编写的,我正在使用HTTParty处理与Web服务的通信。 我的代码如下(我仍然是Ruby / Rails的新手,对下面包含的任何不良做法感到抱歉。我很乐意向我指出这些错误):
class ReaderUser

    # Include HTTParty - this handles all the GET and POST requests.
    include HTTParty

    ...

    def add_feed(feed_url)

      # Prepare the query
      url = \"http://www.google.com/reader/api/0/subscription/quickadd?client=scroll\"
      query = { :quickadd => feed_url, :ac => \'subscribe\', :T => @token }
      query_as_string = \"quickadd=#{CGI::escape(feed_url)}&ac=subscribe&T=#{CGI::escape(@token.to_s)}\"
      headers = { \"Content-type\" => \"application/x-www-form-urlencoded; charset=UTF-8\", \"Content-Length\" => query_as_string.length.to_s, \"Authorization\" => \"GoogleLogin auth=#{@auth}\" }

      # Execute the query
      self.class.post(url, :query => query, :headers => headers)

    end

    ...

end
供参考,这是我获取令牌的方式:
# Obtains a token from reader
# This is required to \'post\' items
def get_token

    # Populate @auth
    get_auth

    # Prepare the query
    url = \'http://www.google.com/reader/api/0/token\'
    headers = {\"Content-type\" => \"application/x-www-form-urlencoded\", \"Authorization\" => \"GoogleLogin auth=#{@auth}\" }

    # Execute the query
    @token = self.class.get(url, :headers => headers)

end

# Obtains the auth value.
# This is required to obtain the token and for other queries.
def get_auth

    # Prepare the query
    url = \'https://www.google.com/accounts/ClientLogin\'
    query = { :service => \'reader\', :Email => @username, :Passwd => @password }

    # Execute the query
    data = self.class.get(url, :query => query)

    # Find the string positions of AUTH
    auth_index = data.index(\"Auth=\") + 5

    # Now extract the values of the auth
    @auth = data[auth_index,data.length]

end
我很乐意提供所需的任何其他信息。 提前致谢!     
已邀请:
经过大量的混乱,我找到了解决方案! 我只需要将Content-Length设置为\“ 0 \”。以前,我根据我基于它的PHP类(greader.class.php)将其设置为\'query \'的长度。我提到这一点是为了防止其他人遇到相同的问题。     

要回复问题请先登录注册