我使用更快的框架来使用特定的哈希标签获取tweet,但我也需要用户的图像和名称。
使用这种方法,我可以获得tweet文本,我可以从JSON响应、概要文件图像和用户名中读取,但是我无法将它放入变量中。
PS:不介意for索引0.19它只是测试
let swifter = Swifter(consumerKey: "MyConsumerKey", consumerSecret: "MyConsumerSecret", appOnly: true)
swifter.authorizeAppOnlyWithSuccess({ (accessToken, response) -> Void in
swifter.getSearchTweetsWithQuery("%23realmadrid", geocode: nil, lang: nil, locale: nil, resultType: nil, count: 20, until: nil, sinceID: nil, maxID: nil, includeEntities: true, callback: nil, success: { (statuses, searchMetadata) -> Void in
for index in 0...19 {
if let statusText = statuses?[index]["text"].string {
self.tweetsArray.addObject(statusText)
}
if let statusName = statuses?[index]["screen_name"].string {
println("@%@", statusName)
}
if let statusImage = statuses?[index]["profile_image_url"].string {
println("@%@", statusImage)
}
}
self.tableView.reloadData()
}, failure: { (error) -> Void in
})
}, failure: { (error) -> Void in
println("error")
})发布于 2015-04-01 15:37:22
任何发现同样问题的人:
if let statusName = statuses?[index]["user"]["screen_name"].string {
tweetsDictionary.setObject(statusName, forKey: "name")
}
if let statusImage = statuses?[index]["user"]["profile_image_url"].string {
var string = statusImage.stringByReplacingOccurrencesOfString("_normal", withString: "", options: NSStringCompareOptions.BackwardsSearch, range: nil)
tweetsDictionary.setObject(string, forKey: "image")
}它以用户上传的质量检索twitter用户名和概要文件图像。
https://stackoverflow.com/questions/29042785
复制相似问题