Jump to content

Facebook login / chat


Recommended Posts

Hi, im trying to make a small facebook messenger, but normally that i have problem since im here :)

How to get all friend and chat with them ? over TCP or UDP ?

And now window is not hidden but in future will be and process too.

Im not so good in explaining things but here is code

#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <GUIListBox.au3>
#include <IE.au3>

Global $window = _IECreate('https://www.facebook.com/', 0, 0, 1), $Form1, $login, $email, $password, $stayLogged

Local $oWbn = _IEGetObjById($window, "pagelet_welcome_box")

If IsObj($oWbn) = 0 Then
;~  MsgBox(0, '', 'not logged')

    $Form1 = GUICreate("Facebook messenger", 359, 210, 338, 218)
    GUICtrlCreateGroup("", 10, 8, 337, 137)
    GUICtrlSetFont(-1, 10, 800, 0, "Calibri")
    GUICtrlCreateLabel("Email :", 64, 36, 40, 19)
    $email = GUICtrlCreateInput("", 107, 32, 217, 23)
    GUICtrlCreateLabel("Password :", 41, 73, 63, 19)
    $password = GUICtrlCreateInput("", 107, 70, 217, 23, BitOR($GUI_SS_DEFAULT_INPUT,$ES_PASSWORD))
    $stayLogged = GUICtrlCreateCheckbox("Stay logged", 107, 104, 97, 17)
    GUICtrlCreateGroup("", -99, -99, 1, 1)
    $login = GUICtrlCreateButton("Login", 10, 156, 337, 41)
    GUICtrlSetFont(-1, 12, 800, 0, "Calibri")


    ; if already logged in show other form
;~  MsgBox(0, '', 'logged in')
    $Form2 = GUICreate("Facebook Chat", 448, 466, 299, 146)
    $friendlist = GUICtrlCreateList("", 16, 16, 417, 266)
    $chatwindow = GUICtrlCreateList("", 16, 296, 417, 97)
    $text = GUICtrlCreateInput("", 16, 392, 417, 21)
    $sendBtn = GUICtrlCreateButton("Send", 360, 424, 75, 25)
    $logout = GUICtrlCreateButton("Logout", 16, 424, 75, 25)


While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
        Case $login
        Case $sendBtn


; check login
Func _checkLogin()

    If IsObj($oWbn) = 0 Then ; if not logged in

        ; check if empty fields
        If GUICtrlRead($email) == '' Or GUICtrlRead($password) == '' Then
            MsgBox(64, 'Info', 'Please enter email and password')
                - opens hidden internet explorer window
                - opens facebook page
                - get ID's form, email, password, remember me, and submit button
                - set values from GUI
                - submit form
            $formID = _IEGetObjById($window, 'login_form')
            $emailID = _IEGetObjById($window, 'email')
            $passID = _IEGetObjById($window, 'pass')
            $rememberID = _IEGetObjById($window, 'persist_box')
            $loginBtnID = _IEGetObjById($window, 'u_0_v')

            _IEFormElementSetValue($emailID, GUICtrlRead($email)) ; set email
            _IEFormElementSetValue($passID, GuictrlRead($password)) ; set password

            ; check for stay logged checkbox
            If GUICtrlRead($stayLogged) = $GUI_CHECKED Then
                _IEFormElementCheckBoxSelect($formID, 'persistent', '', 1, 'byIndex')

            _IEFormSubmit($formID) ; submit form

        EndIf ;=> login form

    EndIf ;=> if not logged in

EndFunc ;=> check login

; send message
Func _sendMsg()
    GUICtrlSetData($chatwindow, GUICtrlRead($text))


Edited by akira2891
Link to comment
Share on other sites

Hey Akira2891,

Facebook have tools that can assist you in building your messenger client. The last time I looked into this, they were using a facebook chat API. However a quick search shows that they've depreciated the api, and removed XMPP permissions for the messenger.

At first glance it seems like they're forcing developers to link to their messenger app and integrate with it, as opposed to allowing developers to integrate with it directly. (Notice here).

I'm not trying to discourage you, But the only way I can think of doing this, is to do utilise the Graph API they currently have (Found here); That contains Get requests for retrieving friends lists/ Messages etc... It may actually even be able to handle POST responses for messages; I haven't looked to in depth.

I would suggest reading the documentation on facebook's developer site, head over to W3Schools and school yourself on GET vs POST HTTP requests, and look into HTTP GET/POST requests on the forums here for examples on how to use them within AutoIT, (Example)

what you're trying to achieve is no small task, And I honestly believe that using the API will, although initially be harder to comprehend and implement successfully, would be a much better approach than trying to hide the facebook website in the background, And trying to send messages through the messenger portion of the website.

If you are still considering using a hidden browser window as your approach to this, then i would suggest you use www.messenger.com as this is facebooks website version of it's Messenger app.

Hopefully my ramblings help you, And best of luck.


give a man an application, and he'll be frustrated for the day, Teach him how to program applications and he'll be frustrated for a lifetime.

Link to comment
Share on other sites

I saw they removed API for messenger that day when they shut off their tool, so it will be hard way to get this to work especialy because i didnt worked with facebook API's never.

I have a decent knowledge in php but i will try to make it without php, because for php i need hosting to upload a script with code.

But again i think it's a best way to hide browser in background.

Anyway thanks for your reply.




Link to comment
Share on other sites

Why are you re-inventing the wheel?

UDF List:

_AdapterConnections()_AlwaysRun()_AppMon()_AppMonEx()_ArrayFilter/_ArrayReduce_BinaryBin()_CheckMsgBox()_CmdLineRaw()_ContextMenu()_ConvertLHWebColor()/_ConvertSHWebColor()_DesktopDimensions()_DisplayPassword()_DotNet_Load()/_DotNet_Unload()_Fibonacci()_FileCompare()_FileCompareContents()_FileNameByHandle()_FilePrefix/SRE()_FindInFile()_GetBackgroundColor()/_SetBackgroundColor()_GetConrolID()_GetCtrlClass()_GetDirectoryFormat()_GetDriveMediaType()_GetFilename()/_GetFilenameExt()_GetHardwareID()_GetIP()_GetIP_Country()_GetOSLanguage()_GetSavedSource()_GetStringSize()_GetSystemPaths()_GetURLImage()_GIFImage()_GoogleWeather()_GUICtrlCreateGroup()_GUICtrlListBox_CreateArray()_GUICtrlListView_CreateArray()_GUICtrlListView_SaveCSV()_GUICtrlListView_SaveHTML()_GUICtrlListView_SaveTxt()_GUICtrlListView_SaveXML()_GUICtrlMenu_Recent()_GUICtrlMenu_SetItemImage()_GUICtrlTreeView_CreateArray()_GUIDisable()_GUIImageList_SetIconFromHandle()_GUIRegisterMsg()_GUISetIcon()_Icon_Clear()/_Icon_Set()_IdleTime()_InetGet()_InetGetGUI()_InetGetProgress()_IPDetails()_IsFileOlder()_IsGUID()_IsHex()_IsPalindrome()_IsRegKey()_IsStringRegExp()_IsSystemDrive()_IsUPX()_IsValidType()_IsWebColor()_Language()_Log()_MicrosoftInternetConnectivity()_MSDNDataType()_PathFull/GetRelative/Split()_PathSplitEx()_PrintFromArray()_ProgressSetMarquee()_ReDim()_RockPaperScissors()/_RockPaperScissorsLizardSpock()_ScrollingCredits_SelfDelete()_SelfRename()_SelfUpdate()_SendTo()_ShellAll()_ShellFile()_ShellFolder()_SingletonHWID()_SingletonPID()_Startup()_StringCompact()_StringIsValid()_StringRegExpMetaCharacters()_StringReplaceWholeWord()_StringStripChars()_Temperature()_TrialPeriod()_UKToUSDate()/_USToUKDate()_WinAPI_Create_CTL_CODE()_WinAPI_CreateGUID()_WMIDateStringToDate()/_DateToWMIDateString()Au3 script parsingAutoIt SearchAutoIt3 PortableAutoIt3WrapperToPragmaAutoItWinGetTitle()/AutoItWinSetTitle()CodingDirToHTML5FileInstallrFileReadLastChars()GeoIP databaseGUI - Only Close ButtonGUI ExamplesGUICtrlDeleteImage()GUICtrlGetBkColor()GUICtrlGetStyle()GUIEventsGUIGetBkColor()Int_Parse() & Int_TryParse()IsISBN()LockFile()Mapping CtrlIDsOOP in AutoItParseHeadersToSciTE()PasswordValidPasteBinPosts Per DayPreExpandProtect GlobalsQueue()Resource UpdateResourcesExSciTE JumpSettings INISHELLHOOKShunting-YardSignature CreatorStack()Stopwatch()StringAddLF()/StringStripLF()StringEOLToCRLF()VSCROLLWM_COPYDATAMore Examples...

Updated: 22/04/2018

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Create New...