PDA

View Full Version : My First Real Program


__Yautja__
06-10-2004, 12:32 AM
Well I have just started my first program that I think will be useful to myself. It logins into yahoo and checks to see if u have any mail. Only problem is I can't figure out how to login to yahoo using winsock. I tried this so far:

Private Sub Command1_Click()
WSock.SendData ("http://login.yahoo.com/config/login?.tries=1&.src=&.md5=&.hash=&.js=1&.last=&promo=&.intl=us&.bypass=&.partner=&.u=5hi8hg90cfnlq&.v=0&.challenge=OHwUAYIfQkTKZPVCMv.MvIoaqCeg&.yplus=&.emailCode=&pkg=&stepid=&.ev=&hasMsgr=1&.chkP=Y&.done=http%3A//my.yahoo.com&login="MY NAME"&passwd="MY PASSWORD"&.persistent=&.save=1&.hash=1&.md5=1")
End Sub
__________________________________________________
Private Sub Command3_Click()
End
End Sub
__________________________________________________
Private Sub Form_Load()
WSock.Close
WSock.RemoteHost = "216.109.127.60"
WSock.RemotePort = 80
WSock.Connect
End Sub
__________________________________________________ ___




i had no luck. Can anyone help me? Thanks. :)

Limpkinw
06-10-2004, 12:30 PM
because mail uses a secure HTTP type connection you will not be able to connect using winsock. Stick with INet you should be fine.

baloney_mahoney
06-10-2004, 04:02 PM
Your usage of Winsock is incorrect.

Try the following code. It will get you to where you are trying to get to but I can't say that your parameters are correct but it will return data to your program.

Dim Return_Data As String

Private Sub Form_Load()
End Sub

Private Sub Command1_Click()
WSock.Close

WSock.RemoteHost = "login.yahoo.com"

WSock.RemotePort = 80
WSock.Connect
End Sub

Private Sub WSock_Connect()
Return_Data = ""

s3 = ".tries=1&.src=&.md5=&.hash=&.js=1&.last=&promo=&.intl=us&.bypass=&.partner=&.u=5hi8hg90cfnlq&.v=0&.challenge=OHwUAYIfQkTKZPVCMv.MvIoaqCeg&.yplus=&.emailCode=&pkg=&stepid=&.ev=&hasMsgr=1&.chkP=Y&.done=http%3A//my.yahoo.com&login=your_id&passwd=your_password&.persistent=&.save=1&.hash=1&.md5=1" & vbCrLf

s1 = "POST /config/login HTTP/1.0" & vbCrLf
s2 = "Content-length: " & Str(Len(s3)) & vbCrLf & vbCrLf

WSock.SendData s1 & s2 & s3

End Sub

Private Sub WSock_DataArrival(ByVal bytesTotal As Long)
WSock.GetData s1, vbString
Return_Data = Return_Data & s1
End Sub

Private Sub WSock_Close()
WSock.Close
Open "RETURN_DATA.txt" For Output As #1
Print #1, Return_Data
Close #1
End Sub

Limpkinw
06-10-2004, 05:22 PM
He will not be able to retrieve mail or do any mail functions with winsock....

baloney_mahoney
06-10-2004, 05:37 PM
He will not be able to retrieve mail or do any mail functions with winsock....

You're right about that as far as what he was trying to do but I didn't post that because I thought it would actually retrieve his email from Yahoo it was just the correct way to do what he was trying to do, whatever that was.

I write email programs all the time using Winsock. I am not saying that he will be able to get Yahoo email, per se, but in general you can use Winsock to retrieve email as long as you know SMTP.

The rule of thumb is that you can use Winsock for any type of data transfer as long as you know the correct protocols.

Limpkinw
06-10-2004, 06:00 PM
yahoo mail doesnt use smtp, unless u have a premium type account. thus u have to use INet

baloney_mahoney
06-10-2004, 06:37 PM
yahoo mail doesnt use smtp, unless u have a premium type account. thus u have to use INet

OK, I agree with you. Like I said.....my posting was to correct his way of doing whatever he was trying to do.

And no, you do not have to use INet (maybe he does). You can still use Winsock to access Yahoo email; so, if it isn't SMTP then you need to know what protocol you have to use, but given the correct protocol in your application it is no different than any other data transfer operation. Keep in mind, Inet is just an outter shell of Winsock to make things simple for you and me.

Limpkinw
06-10-2004, 06:57 PM
Inet uses internet explorer as a shell. Good luck gettin winsock to connect to a secure connection (anything https) they have teams working on figuring out how to do this. I woudl like to see a project using winsock connect to https sucessfully.

baloney_mahoney
06-10-2004, 06:58 PM
OK, let me put it in another way.........

If you can go to Yahoo using your browser, login to your account, go to your email and view your mail in the browser window then you can do exactly the same thing in a program using either Inet or Winsock. Which one you use doesn't matter, it all a matter of preference and Inet is by far the easiest way to do it but Winsock gives you more control of how you want to handle the communications. Anything that the browser can do, you also can do using Winsock if you know how to code Winsock.

Although I don't recommend Leb using Winsock unless he wants the challange he would be better off to use Inet like you mentioned.

Limpkinw
06-10-2004, 07:06 PM
why dont u try it then. I know what im talkin about :) anything that comes thru https is encrypted. I would like to see a winsock program that retrieves yahoo mail (other than thru smtp)

Limpkinw
06-10-2004, 07:09 PM
without any type of wrapper i mean of course.

baloney_mahoney
06-10-2004, 07:13 PM
Inet uses internet explorer as a shell. Good luck gettin winsock to connect to a secure connection (anything https) they have teams working on figuring out how to do this. I woudl like to see a project using winsock connect to https sucessfully.

Yes, and Internet Explorer, or the DLL that makes up IE uses Winsock as the means to make data transfer connections. In the Windows world, Winsock is the bottom line for all Internet data transfers. If you can't do it with the Winsck.OCK then you have to use the Winsock DLL. And that is where you can connect to a secure server (https). You connect to a HTTPS server via port 443 (not 80). Once connected you need to pass back the correct handshacking protocol (not covered in the Winsock manual).

If you like, I will see if I can put one of my https applications (.exe only) that I had to write for the company I work for on my web site and you can d/l it and see it. I can't supply the source code as that would really get me into hot water.

Limpkinw
06-10-2004, 07:21 PM
winsock of course is the basis for data transfer in windows, however winsock.ocx as is used in vb w/out any help will not communicate effectively with a secure server.
I really would like to see someone prove me wrong.

Realged13
06-10-2004, 07:25 PM
I'm going to have to go on this one because I'm sure Limp knows what he is talking about.

Limpkinw
06-10-2004, 07:34 PM
well in a way both r correct but no way will a new programmer be writting a program to communicate with a https server. I misread the original post and thus this tangent resulted.

baloney_mahoney
06-10-2004, 07:57 PM
winsock of course is the basis for data transfer in windows, however winsock.ocx as is used in vb w/out any help will not communicate effectively with a secure server.
I really would like to see someone prove me wrong.

Agreed, perhaps (never tried it in VB). So, if not the OCX then you write your own Winsock layer making calls to the Winsock DLL. I'm only saying that it can be done using Winsock not wheather you or Leb or me or anyone has the know-how to do so (in VB, dont use the OCX, use the DLL instead).

The company I work for has a bunch of applications that communicate with https servers but they do it in C and not VB. But the concept is the same wheather in C or VB.

I believe the point was wheather or not one can use Winsock to retrieve the Yahoo email (not smtp) and not wheather or not one has the "know-how". I do not have alot of Yahoo know-how so it would be a challange for me to write a C or VB program to get Yahoo email. But that has nothing to do with wheather it can be done or not. I can write a C program (using Winsock) to communicate to a https server just not to Yahoo https server. Maybe I will give it a try (after I learn some Yahoo ins and outs) just to see.

P.S. You new site is a 150% improvement over your earlier one. Good job, btw.