擅长:python、mysql、java
<p>我们可以使用ASK SDK for python中的函数<code>get_account_linking_access_token()</code>来获取用于帐户链接的用户令牌
并存储在变量<code>account_linking_token</code>中。如果已完成帐户链接,则使用令牌获取用户数据,如下所示:</p>
<pre><code>from ask_sdk_model.ui import SimpleCard
speech_output = ''
if account_linking_token is not None:
url = "https://api.amazon.com/user/profile?access_token{}"\
.format(account_linking_token)
user_data = requests.get(url).json()
# retrieve the required user info here and populate output
# speech_output = ...
else:
# output msg when account linking is not done
# speech_output = ...
# return this response from the intent handler function
response = handler_input.response_builder
.speak(speech_output)
.ask(reprompt)
.set_card(SimpleCard(speech_output))
.response
</code></pre>