运行OAuthSwift时出现问题

时间:2015-08-14 05:34:06

标签: ios xcode swift oauth twitter-oauth

我正在使用OAuthSwift,每当我运行此功能时

func doOAuthTwitter(){
    let oauthswift = OAuth1Swift(
        consumerKey:   "...",
        consumerSecret: "...",
        requestTokenUrl: "https://api.twitter.com/oauth/request_token",
        authorizeUrl:    "https://api.twitter.com/oauth/authorize",
        accessTokenUrl:  "https://api.twitter.com/oauth/access_token"
    )
    oauthswift.authorize_url_handler = WebViewController()
    oauthswift.authorizeWithCallbackURL( NSURL(string: "oauth-swift://oauth-callback/twitter")!, success: {
        credential, response in
        self.showAlertView("Twitter", message: "auth_token:\(credential.oauth_token)\n\noauth_toke_secret:\(credential.oauth_token_secret)")
        var parameters =  Dictionary<String, AnyObject>()
        oauthswift.client.get("https://api.twitter.com/1.1/statuses/home_timeline.json", parameters: parameters,
            success: {
                data, response in
                let jsonDict: AnyObject! = NSJSONSerialization.JSONObjectWithData(data, options: nil, error: nil)
                println(jsonDict)
            }, failure: {(error:NSError!) -> Void in
                println(error)
        })
        }, failure: {(error:NSError!) -> Void in
            println(error.localizedDescription)
        }
    )
}

该功能似乎一直持续到这一点之后

oauthswift.authorize_url_handler = WebViewController()

authorizeWithCallbackURL甚至没有启动,并且jsonDict不会打印。我已经通过OAuthSwift演示尝试了我的访问代码,它可以与tableView一起使用,打印出JsonDict。我不知道为什么在我在演示之外使用authorizeWithCallbackURL时会完全忽略它。

0 个答案:

没有答案
相关问题