Titanium Community Questions & Answer Archive

We felt that 6+ years of knowledge should not die so this is the Titanium Community Questions & Answer Archive

Titanium.Network.createHTTPClient() authenticate error

Hello.
I try to use this code:

<?xml version="1.0" encoding="utf-8"?>  
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8"/>
</head> 
<body>
<script type="text/javascript">
        function click_action(){
            var un = document.getElementById('username').value;
            var pw = document.getElementById('password').value;

            try {
                var xhr = Titanium.Network.createHTTPClient();
                xhr.onload = function() {
                    //do work on "this.responseXML"
                    alert(this);
                };
                xhr.open("GET","http://"+un+":"+
pw+"@twitter.com/account/verify_credentials.xml");
                xhr.send();
            } 
            catch(err) {
                Titanium.UI.createAlertDialog({
                    title: "Error",
                    message: String(err),
                    buttonNames: ['OK']
                }).show();
            }
        }
        </script>
<input type="text" id="username"/><br/>
<input type="password" id="password"/><br/>
<input type="button" onclick="click_action()" value="click me!"/>    
    </body>
</html>

But it returnes error on authenticate. Please, help me, what is it mistake in this code?

— asked March 30th 2010 by vladimir vashurin
  • desktop
0 Comments

2 Answers

  • Hrm. You may be running into this bug https://appcelerator.lighthouseapp.com/projects/25719/tickets/335-titaniumnetworkhttpclient-does-not-fire-onload

    Can you try adding this line before you send the request and see if it helps:
    client.onreadystatechange = function() {};

    — answered March 30th 2010 by Martin Robinson
    permalink
    0 Comments
  • Might not be related, but you should really use the twitter 'https' of that credentials url (despite the fact that their docs only use 'http')

    — answered March 30th 2010 by Kosso
    permalink
    0 Comments
The ownership of individual contributions to this community generated content is retained by the authors of their contributions.
All trademarks remain the property of the respective owner.