2016-04-03 14 views
0

我刚刚完成了电影我的应用程序到解析服务器。除了我的Twitter登录和注册外,我已经完成了所有工作。当我登录或注册时,我收到打印到我的控制台的内部服务器错误消息。我正在使用最新的Parse SDK。这里是我的登录代码(我的注册代码是相似的,它只是会从Twitter的API等数据,并将其存储到我的数据库):ParseTwitterUtils内部服务器错误

PFTwitterUtils.logInWithBlock { 
      (user: PFUser?, error: NSError?) -> Void in 

      if let user = user { 

       if user.isNew { 

        spinningActivity.hideAnimated(true) 

        PFUser.currentUser()?.deleteInBackground() 

        self.displayNoticeWithTwoActions("Account Not Found", message: "This Twitter account is not in our system. You have to sign up first.", firstButtonTitle: "Sign Up", closeButtonTitle: "Ok", segue: "dontHaveAccountSegue") 


       } else if error != nil { 

        spinningActivity.hideAnimated(true) 

        self.displayError("Error", message: error!.localizedDescription) 

       } else { 

        spinningActivity.hideAnimated(true) 
        self.performSegueWithIdentifier("successfulLoginSegue", sender: self) 

       } 


      } else { 

       spinningActivity.hideAnimated(true) 


       self.displayError("Error", message: "Unless you tapped on 'Cancel' or 'Done', something went wrong. Please try again.") 

      } 
     } 

我能在网上找到的唯一的事情是,它可能是一个问题在推特的最后......我确信我的消费者密钥和秘密在我的AppDelegate中是正确的。有任何想法吗?

+0

你必须到你的Twitter身份验证密钥添加到您的解析服务器的配置文件 – pbush25

+0

在我情况下,我在Heroku上使用Parse Server。这是否意味着我会将一个密钥TWITTER_AUTH添加到密钥列表中?建议我将我的Facebook密钥添加到列表中吗? Facebook登录和注册在没有服务器上列出的密钥的情况下工作。我感谢您的帮助! –

回答

2

要将index.js文件是解析服务器的配置文件,你需要补充一点:

var api = new ParseServer ({ 
    databaseURI: xxxxxxx, 
    cloud: xxxxxx, 
    appID: xxxxxx, 
    //more keys 
    //add oauth keys 
    oauth: { 
     facebook: { 
      appIds: xxxxxxxxxxxxx 
     }, 
     twitter: { 
      appIds: xxxxxxxxxxxxx 
     } 
    } 
}) 
+0

我没有index.js文件,因为我在Heroku上托管服务器。但是,我可以选择在Heroku中添加密钥。你知道Facebook和Twitter的关键名字是什么吗?我只是做“钥匙”= Facebook和“价值”= appId以及“钥匙”= Twitter和“价值”= consumerKey? –

+0

您可以使用他们的命令行工具从Heroku中克隆您的项目,修改index.js文件,然后将更改推回到Heroku。 – pbush25

+0

查看这里的链接:https://devcenter.heroku.com/articles/heroku-command和这里:https://devcenter.heroku.com/articles/getting-started-with-nodejs#push-local-changes – pbush25