我们似乎无法根据 Google Docs API 创建新的电子表格。
我们的请求只是挂起。我们在 Rails 3.0.6 上。
这是我们的代码:
msg = '<atom:entry xmlns:atom="http://www.w3.org/2005/Atom">
<atom:category scheme="http://schemas.google.com/g/2005#kind"
term="http://schemas.google.com/docs/2007#document" />
<atom:title>Company Perks</atom:title>
</atom:entry>'
oauth_base_string = 'POST&http://docs.google.com/feeds/documents/private/full&oauth_consumer_key=DOMAIN&oauth_nonce=1c4fbbe4387a685829d5938a3d97988c&oauth_signature_method=HMAC-SHA1&oauth_timestamp=1227303732&oauth_version=1.0&xoauth_requestor_id=ID'
key = 'KEY'
oauth_signature = CGI.escape(Base64.encode64("#{OpenSSL::HMAC.digest('sha1', key, oauth_base_string)}"))
headers = {
'Content-Type' => 'application/atom+xml',
'Authorization' => 'OAuth oauth_consumer_key="DOMAIN",oauth_nonce"1c4fbbe4387a685829d5938a3d97988c",oauth_signature=' + oauth_signature + ',oauth_signature_method="HMAC-SHA1",oauth_timestamp="1227303732",oauth_version="1.0"'
}
uri = URI.parse 'http://docs.google.com/feeds/documents/private/full?xoauth_requestor_id=ID'
http = Net::HTTP.new uri.host, uri.port
http.verify_mode = OpenSSL::SSL::VERIFY_NONE
http.use_ssl = true
resp, data = http.post(uri.request_uri, msg, headers)
传奇:
DOMAIN = OAuth 消费者密钥 ID = 我们尝试为其创建新电子表格的电子邮件地址 KEY = OAuth 消费者密钥