我们正在尝试为我们自己的频道检索 Youtube 分析数据。我们正在使用 GTLQueryYouTubeAnalytics。这是一个使用 Xcode 6 用 Swift 编写的 iPhone 应用程序
这就是我们所拥有的:
var scope = "https://www.googleapis.com/auth/youtube https://www.googleapis.com/auth/yt-analytics-monetary.readonly https://www.googleapis.com/auth/yt-analytics.readonly https://www.googleapis.com/auth/youtubepartner https://www.googleapis.com/auth/youtube.readonly"
var vc = GTMOAuth2ViewControllerTouch(scope: scope, clientID: clientID, clientSecret: clientSecret, keychainItemName: kKeyChainItemName, delegate: self, finishedSelector:Selector("authentication:finishedWithAuth:error:"))
In authentication(){
....
....
// On Success
service = GTLServiceYouTube()
service.authorizer = finishedWithAuth
// Channel is my Channel ID
var newQuery: GTLQueryYouTubeAnalytics = GTLQueryYouTubeAnalytics.queryForReportsQueryWithIds("channel==*****", startDate: "2014-10-15", endDate: "2014-10-16", metrics: "views,likes,shares,comments") as GTLQueryYouTubeAnalytics
var ticket1 = GTLServiceTicket()
ticket1 = service.executeQuery(newQuery, completionHandler: { (ticket: GTLServiceTicket!, object: AnyObject!, error: NSError!) -> Void in
println("Analytics: \(object) or \(error)")
})
}
这是我的输出:
Analytics: nil or Error Domain=com.google.GTLJSONRPCErrorDomain Code=404 "The operation couldn’t be completed. (Not Found)" UserInfo=0x***** {error=Not Found, NSLocalizedFailureReason=(Not Found), GTLStructuredError=GTLErrorObject 0x7f8e43ddc9b0: {message:"Not Found" data:[1] code:404}}
我们在这里缺少什么?我们为 YouTubeDataAPI 运行了先前的查询,并且运行良好。
任何想法表示赞赏!