Recent Widgets


Register for DashboardWidgets

Recent Forums Posts

Partners


iCompositions

MacDesktops.net

RSS Showcase
RSS Comments
RSS Forums

This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies. Posted in: Widget Development

How to send Login/Password to site

Author Message
rmathus



Joined: 18 Jun 2005
Posts: 20

Posted: Fri Jun 24, 2005 - 9:54 pm    Post subject: How to send Login/Password to site Reply with quote

Hi all!

I need a little bit of help - I know very little Javascript (it's my next course next semester in college so bear with me!) and I've been searching this forum and others trying to figure out how to do this.

I'm programming a widget to play XM Radio Online. There seems to be a problem with this code (I've commented out a few lines for testing certain ways of sending the data). The data (userID, password, speed, and channel) all come from the back of the widget when entered by the user. XM's site uses cookies (could that be the problem?) and it doesn't look like the data in the widget is being sent to XM at all since it just gives me the default stream from XM saying "You're not logged in. Please try again."

Here's the code. If you need more or a better explanation, please let me know. Thanks for the help in advance - great site here, and looking forward to learning more and making some cool widgets!
-Ryan

Code:
   if (window.widget)      // always check to make sure that you are running in Dashboard
      {
         myUIDString = widget.preferenceForKey("myUID");
         myPASSString = widget.preferenceForKey("myPASS");   
         mySPEEDString = widget.preferenceForKey("mySPEED");   
         myCHANString = widget.preferenceForKey("myCHAN");

         if (myUIDString && myUIDString.length > 0)  { document.getElementById("myUID").value = myUIDString; }
         if (myPASSString && myPASSString.length > 0)  { document.getElementById("myPASS").value = myPASSString; }
         if (mySPEEDString && mySPEEDString.length > 0)  { document.getElementById("mySPEED").value = mySPEEDString; }
         if (myCHANString && myCHANString.length > 0)  { document.getElementById("myCHAN").value = myCHANString; }
         
          createGenericButton(document.getElementById("donePrefsButton"),"Done",hidePrefs,60)
             document.getElementById("donePrefsButton").display = "none";
   
   
          // send the data to XM
          //var xmlhttp = new XMLHttpRequest();
         //xmlhttp.open("GET", "http://xmro.xmradio.com/xstream/login_servlet.jsp?user_id=" + myUID + "&pword=" + myPASS + "");   
         //xmlhttp.overrideMimeType("text/html");
         
         req = new XMLHttpRequest()
         url = "http://xmro.xmradio.com/xstream/index.jsp"
         req.open("POST", url ,false)
         req.send("user_id=" + myUID + "&pword=" + myPASS)
         x = req.responseText

          
         // display the artist, song title, and album title of what's playing   
         var displayURL = "http://player.xmradio.com/padData/pad_data_servlet.jsp?channel="
         xmURL3 = displayURL + myCHAN;
         
      } // end if
View user's profile Send private message Widgets
Mayhem



Joined: 18 May 2005
Posts: 63
Location: Stockholm, Sweden

Posted: Sat Jun 25, 2005 - 6:29 am    Post subject: Reply with quote

Unless the site you're interacting with just slaps the username and password onto all its URL:s while logged in you can't expect that to work, most likely you'll need to perform two separate requests. First, send your credentials (username/password) to the URL specified in the action attribute of the login form in order to receive tickets (cookies). Second, fetch the desired resource whereby the tickets should be automatically included to validate your request.
_________________
Give me one more medicated peaceful moment
View user's profile Send private message Send e-mail Visit poster's website MSN MessengerWidgets
rmathus



Joined: 18 Jun 2005
Posts: 20

Posted: Sat Jun 25, 2005 - 5:09 pm    Post subject: Reply with quote

I think I understand (please correct me if I'm wrong!). The only URL that XM has with the login/password in it is the login URL (which is http://xmro.xmradio.com/xstream/login_servlet.jsp?user_id=" + myUID + "&pword=" + myPASS) but all other URL's check to see if a user is logged in first.

So I should first send the credentials, which is obvious and which I can do in the function setup() (which is what all of the above code is in). I have the actual player and URL to the channel as specified by the user in the HTML file, but it still defaults to the "You're not logged in" audio message by XM which leads me to believe that nothing's actually being sent to XM, I think.

The part I'm a bit confused about is the following:
Mayhem wrote:
Second, fetch the desired resource whereby the tickets should be automatically included to validate your request.

I'm not quite sure what you mean...care to make a bit more clear or elaborate? Thanks for hanging in there with this and once again, thanks for the help!
-Ryan
View user's profile Send private message Widgets
Mayhem



Joined: 18 May 2005
Posts: 63
Location: Stockholm, Sweden

Posted: Sun Jun 26, 2005 - 8:39 am    Post subject: Reply with quote

rmathus wrote:
I'm not quite sure what you mean...care to make a bit more clear or elaborate? Thanks for hanging in there with this and once again, thanks for the help!

There's nothing to it really, all I'm saying is that WebKit should automatically include your tickets (cookies) with the request so that the server will know you're logged in. I'm still not quite sure how cookies are handled in Dashboard, I know that cookies received in Safari will be included in requests sent by a widget but I'm still unsure whether cookies received by a widget are saved at all. Guess I'll have to find out soon enough as my widget in development is about to face similar issues...
_________________
Give me one more medicated peaceful moment
View user's profile Send private message Send e-mail Visit poster's website MSN MessengerWidgets
truz



Joined: 30 Jun 2005
Posts: 1

Posted: Thu Jun 30, 2005 - 2:45 pm    Post subject: Reply with quote

Im new here and came here in search of this exact thing you are trying to make. An xm radio widget. Ive been wanting one because i listen to O&A at work on my powerbook and a widget for the player would just rock. Wish you luck in your creation.
View user's profile Send private message Send e-mail Widgets
rmathus



Joined: 18 Jun 2005
Posts: 20

Posted: Sun Jul 03, 2005 - 9:55 pm    Post subject: Reply with quote

truz wrote:
Im new here and came here in search of this exact thing you are trying to make. An xm radio widget. Ive been wanting one because i listen to O&A at work on my powerbook and a widget for the player would just rock. Wish you luck in your creation.


Hi truz,

Here's what I have so far...(from another site that I posted on - I encourage you and anyone else you know to work on it as I can't figure it out...)

----
Currently, it doesn't do anything except play the "We're sorry" audio message. I'm encouraging others to work on this with me, as I need some help and would like to see what can be done since this is YOUR software and I'm open to requests

To view it, you'll need to log in via FTP to:
hostname: xmrocks.us
username: anonymous@xmrocks.us
password: xm411

PLEASE read the README file in that directory. It will give you an idea of what needs to be modified and what the current status of the project is. Please feel free to add any updates to that and upload new copies to the server when bugs are fixed and more items are working. I mainly need help with the Javascript aspect of the project, but that's all covered in the README file on the site.

Thanks.
View user's profile Send private message Widgets
Liquidrums



Joined: 17 Jun 2005
Posts: 23
Location: Houston, TX

Posted: Sat Jul 09, 2005 - 12:36 pm    Post subject: Reply with quote

sadly enough, javascript won't let you fill in the form for another website (ie, you loaded the login page with an iFrame and tried to manually fill it in via javascript).

Supposedly because of a security risk Confused
View user's profile Send private message Send e-mail Visit poster's website AIM Address Widgets
gnome
Administrator


Joined: 26 Sep 2004
Posts: 145

Posted: Sat Jul 09, 2005 - 1:53 pm    Post subject: Reply with quote

It would be a pretty big security risk, yes, especially because of autofill in many browsers. Having the capability to adjust (and therefore read) text boxes of another domain would mean you could acquire passwords for any site where you have autofill enabled.
View user's profile Send private message Widgets
Liquidrums



Joined: 17 Jun 2005
Posts: 23
Location: Houston, TX

Posted: Sat Jul 09, 2005 - 2:12 pm    Post subject: Reply with quote

which is a shame. we could have widgets check bank-balances .. there should be a switch (or some registry value) where you can disable auto-complete simply to manually complete a form for a website.
View user's profile Send private message Send e-mail Visit poster's website AIM Address Widgets
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.

 
Powered by phpBB © 2001, 2002 phpBB Group