1

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 コンシューマ シークレット

4

1 に答える 1