Results 1 to 16 of 16

Thread: [RESOLVED] Need help on developing a simple Facebook Messenger

  1. #1

    Thread Starter
    Member
    Join Date
    May 2012
    Posts
    45

    Resolved [RESOLVED] Need help on developing a simple Facebook Messenger

    Hello guys,
    I am wishing to develop a simple Facebook Messenger in vb6. By Messenger I mean, If a user logs in, He will see a list of all online friends and he can chat with them. But, I don't to how to do that. I want to know from where I have to start. Any Ideas or Example programs from you guys are welcomed.
    Not only Time and Tide, even Tech waits for none!


    My Desktop: Intel Pentium G620 + Intel DH61SA|4GB DDR3-1333 RAM|Dell IN1930|WD Caviar Blue 250GB
    My Netbook: Intel Atom N450|2GB DDR2-667 RAM|10.1" WVGA|WD 160GB
    My Notebook: HP Compaq Presario C722TU

  2. #2
    PowerPoster
    Join Date
    Aug 2011
    Location
    B.C., Canada
    Posts
    2,887

    Re: Need help on developing a simple Facebook Messenger

    You would probably have to automate facebook website which is probably against the copyright but its do-able if you know how to use webbrowser control or internet explorer control which are almost the same

  3. #3
    PowerPoster
    Join Date
    Jan 2008
    Posts
    11,074

    Re: Need help on developing a simple Facebook Messenger

    What you are asking for can turn out to be a rather complex and difficult tasks. Your choices would probably be using WebBrowser and communicate with Facebook that way or use Winsock and communicate directly with the Facebook server. In either case you will need to know a few things about Facebook. Not an easy task at all.


    Anything I post is an example only and is not intended to be the only solution, the total solution nor the final solution to your request nor do I claim that it is. If you find it useful then it is entirely up to you to make whatever changes necessary you feel are adequate for your purposes.

  4. #4
    PowerPoster
    Join Date
    Aug 2011
    Location
    B.C., Canada
    Posts
    2,887

    Re: Need help on developing a simple Facebook Messenger

    i dont hav time to mess around right vb right now but this worked the first time for me... might not work just tested once and havent played with it but sometihng like this

    once you signed in try this at the main page of your account where it shows online friends... i will work on it later
    Code:
    Private IE As Object
    
    Private Sub Command1_Click()
    Dim i As Integer
    Dim OnlineUSER As String
    On Error Resume Next
    For i = 0 To 100
    
    OnlineUSER = IE.Document.getElementById("js_" & i).childnodes.Item(0).childnodes.Item(0).innertext
    If Not OnlineUSER = "" Then Debug.Print OnlineUSER
    OnlineUSER = ""
    Next
    End Sub
    
    Private Sub Form_Load()
    Set IE = CreateObject("InternetExplorer.Application")
    
    With IE
      .Silent = True
      .Navigate "www.facebook.com"
      .Visible = True
    End With
    End Sub

  5. #5
    PowerPoster
    Join Date
    Aug 2011
    Location
    B.C., Canada
    Posts
    2,887

    Re: Need help on developing a simple Facebook Messenger

    ok so i did work on it a bit tonight didnt think i would have the time... yes it could be done better probably but i got the friends list working... after this you need to know how to send messages... but i think this is a start... a start that you wanted here you go please try this attachment and let me know if it works for you
    Attached Files Attached Files
    Last edited by Max187Boucher; Nov 27th, 2012 at 03:39 AM.

  6. #6
    PowerPoster
    Join Date
    Aug 2011
    Location
    B.C., Canada
    Posts
    2,887

    Re: Need help on developing a simple Facebook Messenger

    I worked on this a bit more. The only problem is trying to write the message, whicb writting the message is ok, but find the right email or getting to your friends account to message him is a bit more difficult... I am almost there i hope i can post it tonight.

    Anyone tries my example? Is it working? It works for me all the time

  7. #7
    PowerPoster
    Join Date
    Jan 2008
    Posts
    11,074

    Re: Need help on developing a simple Facebook Messenger

    I tried it. It doesn't work for me.


    Anything I post is an example only and is not intended to be the only solution, the total solution nor the final solution to your request nor do I claim that it is. If you find it useful then it is entirely up to you to make whatever changes necessary you feel are adequate for your purposes.

  8. #8
    PowerPoster jcis's Avatar
    Join Date
    Jan 2003
    Location
    Argentina
    Posts
    4,430

    Re: Need help on developing a simple Facebook Messenger

    It needs to be integrated with Facebook or an independent Application would be ok? In the Codebank you'll find a Messenger style client fully functional, Wokawidget was the member that posted it.. let me search.. here it is:

    Badger Messenger, an MSN clone that uses the MSN Network
    Last edited by jcis; Nov 29th, 2012 at 03:01 PM.

  9. #9
    PowerPoster
    Join Date
    Aug 2011
    Location
    B.C., Canada
    Posts
    2,887

    Re: Need help on developing a simple Facebook Messenger

    What errors are you getting jmsrickland? What is not working?

  10. #10
    PowerPoster
    Join Date
    Jan 2008
    Posts
    11,074

    Re: Need help on developing a simple Facebook Messenger

    OK, I'll go through the steps I take:

    1) Run your project

    2) Facebook comes up in I.E. on Sign Up page and also login in options <---- I do not use this

    3) Click on "Login" on your Form

    4) Facebook changes to Login Page <-------- I enter my email & password

    5) Welcome To Facebook, jmsrickland page comes up with pictures of people I know and friends

    6) Click on "Click To Creat Friends List" on your Form

    7) Run-time error: 5 Invalid procedure or argument

    Code:
    Private Sub Command1_Click()
    Dim ElementID As Object, ElementFriends As Object
    Dim ElementID_POS As Long
    Dim ElementFriend_DIV As HTMLDivElement
    Dim Friends As String
    Dim fb_Friends_ID As String
    Dim FriendStatus As String
    
    Screen.MousePointer = vbHourglass
    
    ShowWindow IE.hwnd, SW_MAXIMIZE
    IE.Document.parentWindow.scrollTo 0, 4000
    
    Sleep 3000
    
    For Each ElementID In IE.Document.All
      ElementID_POS = InStr(1, ElementID.innerHTML, "fbChatSidebarBody")
      If ElementID_POS <> 0 Then
        Friends = Mid(ElementID.innerHTML, InStr(ElementID_POS, ElementID.innerHTML, "id=") + Len("id="), (InStr(ElementID_POS, ElementID.innerHTML, "class=") - Len("class=")) - InStr(ElementID_POS, ElementID.innerHTML, "id=") + Len("id="))
        fb_Friends_ID = Trim(Replace(Friends, Chr(34), vbNullString))
        
        Set ElementFriend_DIV = IE.Document.getElementById(fb_Friends_ID)
        
        For Each ElementFriends In ElementFriend_DIV.All
    One problem I notice is that different Facebook pages come up on various attempts to use your project .


    Anything I post is an example only and is not intended to be the only solution, the total solution nor the final solution to your request nor do I claim that it is. If you find it useful then it is entirely up to you to make whatever changes necessary you feel are adequate for your purposes.

  11. #11
    PowerPoster
    Join Date
    Aug 2011
    Location
    B.C., Canada
    Posts
    2,887

    Re: Need help on developing a simple Facebook Messenger

    Hmm what is in the friends string it it is suppose to get the id of the listbox where the friends are online to chat... Its weird that it works for me... Ill have a look at my code and try to split it better maybe i mixed too manu functions the replace, trim, mid

  12. #12

    Thread Starter
    Member
    Join Date
    May 2012
    Posts
    45

    Re: Need help on developing a simple Facebook Messenger

    Guys, sorry for the late reply. Was busy with some other works. Actually, When I was browsing through Facebook's Developer page, I wanted to know if there is any third-party tool for VB6 to build Windows Application for Facebook. After a lot of search, I didn't even find a single one. Once, I get Windows 8, I will try those Developer Tools in VS12.

    BTW, As someone said above, I tried automated login using Browser control. And, I also extracted the online friends' list. But, I am not able to logout. Though I extracted the logout link and made the browser to navigate to the extracted page, It still doesn't logout. So, If a user logs in, he have to open Facebook in IE and logout. Is there any other way to logout from Facebook? (I mean, like deleting cookies, etc..)
    Not only Time and Tide, even Tech waits for none!


    My Desktop: Intel Pentium G620 + Intel DH61SA|4GB DDR3-1333 RAM|Dell IN1930|WD Caviar Blue 250GB
    My Netbook: Intel Atom N450|2GB DDR2-667 RAM|10.1" WVGA|WD 160GB
    My Notebook: HP Compaq Presario C722TU

  13. #13
    PowerPoster
    Join Date
    Aug 2011
    Location
    B.C., Canada
    Posts
    2,887

    Re: Need help on developing a simple Facebook Messenger

    Did you try my little project? Does the friends list work for you? I can show you how to logout, but first let me know if my project worked for your. I have another project somewhere in my computer that used to log in all my accounts (hotmail, facebook, bank, telephone bill, google, youtube) and it also has the option to log out of all those at once... I will look for it tonight

  14. #14

    Thread Starter
    Member
    Join Date
    May 2012
    Posts
    45

    Re: Need help on developing a simple Facebook Messenger

    @Max187Boucher: It did work. But, Opening IE for logging in is somewhat strange. I am waiting for your project which you mentioned above.
    Not only Time and Tide, even Tech waits for none!


    My Desktop: Intel Pentium G620 + Intel DH61SA|4GB DDR3-1333 RAM|Dell IN1930|WD Caviar Blue 250GB
    My Netbook: Intel Atom N450|2GB DDR2-667 RAM|10.1" WVGA|WD 160GB
    My Notebook: HP Compaq Presario C722TU

  15. #15
    PowerPoster
    Join Date
    Aug 2011
    Location
    B.C., Canada
    Posts
    2,887

    Re: Need help on developing a simple Facebook Messenger

    What is strange? Id like to know and i will look for my project in about an hour or so

    Edit: About an Hour later...
    You only need to submit the logout form of facebook

    Code:
    IE.Document.All("logout_form").Submit
    Last edited by Max187Boucher; Dec 6th, 2012 at 07:09 PM.

  16. #16

    Thread Starter
    Member
    Join Date
    May 2012
    Posts
    45

    Re: Need help on developing a simple Facebook Messenger

    What I mentioned as abnormal is If the user can open FB in IE, then he can chat in IE itself. There is no need to use any other application. And moreover, What I want is an automated one. I did it myself. But, Logging out is what I am having problems with. I navigated to Facebook Mobile as it will load quickly and it logged in using browser control. I can send messages without opening IE using browser control. I, then, coded to extract all the links in the Web Page, and searched for Logout in it. After getting the URL, I used the browser control to navigate. But, Sometimes, It just refreshes the page. I think there is some problems with Facebook Mobile. When I logging out from Facebook Mobile in browsers like IE and FF, It did the same. So, that's why I asked for any other way log out like clearing cookies.

    EDIT: When I did as you mentioned above, It throws an error. But somehow, It worked with my code itself. I don't know what happened in a day. Thank God.

    This thread can be closed. Thank you guys, for helping me.
    Last edited by Autistic; Dec 6th, 2012 at 08:39 PM.
    Not only Time and Tide, even Tech waits for none!


    My Desktop: Intel Pentium G620 + Intel DH61SA|4GB DDR3-1333 RAM|Dell IN1930|WD Caviar Blue 250GB
    My Netbook: Intel Atom N450|2GB DDR2-667 RAM|10.1" WVGA|WD 160GB
    My Notebook: HP Compaq Presario C722TU

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width