Tag: google api

如何使用带有Ruby Google API客户端的Gmail API发送消息?

我面临着API的几个问题, 第一: 发送方法询问’id’(消息ID或线程ID)..但为什么? 我正在发送新消息,所以它不应该要求。 根据Gmail Api documnetation它的可选。 https://developers.google.com/gmail/api/v1/reference/users/messages/send ArgumentError: Missing required parameters: id. 第二: 即使在指定消息ID后,它也会返回此消息。 Your client has issued a malformed or illegal request. 码 require ‘mime’ include MIME msg = Mail.new msg.date = Time.now msg.subject = ‘This is important’ msg.headers.set(‘Priority’, ‘urgent’) msg.body = Text.new(‘hello, world!’, ‘plain’, ‘charset’ => ‘us-ascii’) msg.from = {‘hi@gmail.com’ => ‘Boss […]

通过Google Gmail API创建草稿

我正在尝试为登录用户创建草稿消息,但在运行以下内容时不断收到错误Missing draft message require ‘google/api_client’ client = Google::APIClient.new client.authorization.client_id = ENV[‘GOOGLE_CLIENT_ID’] client.authorization.client_secret = ENV[‘GOOGLE_CLIENT_SECRET’] client.authorization.grant_type = ‘refresh_token’ client.authorization.refresh_token = User.last.refresh_token token = client.authorization.fetch_access_token! gmail = client.discovered_api(‘gmail’, ‘v1’) params = { ‘userId’ => ‘me’, ‘draft’ => { ‘message’ => {‘raw’ => ‘test email’ } } } # { ‘userId’ => ‘me’, ‘message’ => {‘raw’ => ‘test […]