2012-06-26 31 views
0

我的問題是我相信我已經構建正確的要求,但我正在逐漸[400 {「消息」:「問題解析JSON」}]GitHub的基本身份驗證

這裏是我的代碼:

var xhr = Ti.Network.createHTTPClient({ 
     onload : function() { 
      Ti.API.debug(this.responseText); 

      json = JSON.parse(this.responseText); 

      callback(json); 
     }, 
     onerror : function(e) { 
      alert('error!'); 
      Ti.API.info(e.error + " " + this.status + " " + this.responseText); 
     } 
    }); 

    xhr.validatesSecureCertificate = true; 
    xhr.open("POST", "https://api.github.com/authorizations"); 
    xhr.setTimeout(10000); 
    authstr = 'Basic ' + Titanium.Utils.base64encode(User.username + ':' + User.password); 
    xhr.setRequestHeader('Authorization', authstr); 
    xhr.send({username: User.username, password: User.password}); 

回答

1

我只是錯過了JSON.stringify方法....在我的身體:P。謝謝!