Android / iOS客户端向服务器API发送access_token和消息。
我试图分享,但没有运气,谷歌的回复是'无效的凭据'。
我试图向客户端添加requestvisibleactions:
client = Google::APIClient.new(requestvisibleactions: ['https://schemas.google.com/AddActivity'])
与client.execute相同。
class GoogleSharer
def self.share(access_token, message, resource)
client = Google::APIClient.new
client.authorization.update_token!(access_token: access_token)
plus = client.discovered_api('plus', 'v1')
moment = {
type: ['http://schemas.google.com/AddActivity'],
target: { name: message, url: get_resource_url(resource) }
}
response = client.execute(api_method: plus.moments.insert, parameters: {collection: 'vault', userId: 'me'}, body_object: moment).body
a = 10
end
end
请指教。感谢。