3
我正在使用Swift使用IBM Watson Tone Analyzer API。我尝试下面的代码:使用Swift的IBM Watson Tone Analyzer API
override func viewDidLoad()
{
print("hello")
super.viewDidLoad()
let username = "USERNAME"
let password = "PASSWORD"
let versionDate = "2016-05-19" // use today's date for the most recent version
let service = ToneAnalyzer(username: username, password: password, version: versionDate)
let failure = { (error: NSError) in print(error) }
service.getTone("Text that you want to get the tone of", failure: failure) { responseTone in
print(responseTone.documentTone)
}
}
对于这一点,我收到以下错误: 错误域= com.alamofire.error代码= -6004“数据不能被序列化解析失败JSON响应无。在序列化过程中提供了错误信息。“ UserInfo = {NSLocalizedFailureReason =数据无法序列化。无法解析JSON响应。在序列化过程中没有提供错误信息。}
我阅读文档,但没有帮助解决此问题。
太棒了!请让我知道你是怎么做的(文档/视频)?我同样尝试使用Personality Insights和其他API – user2609410
我在沃森集团工作。你会发现上面的代码应该适用于任何其他服务(GET调用)并稍加修改。相关服务API文档倾向于拥有您可以使用的示例。 –