blackandwhite Posted February 4, 2016 Share Posted February 4, 2016 Hello everybody! tried everything I can found around web/forums, also trying to clone all headers and POST parameters with data(payload), but this code to upload 1 simple picture to facebook group still sucks & don't returns the page with preview image expandcollapse popup#include <WinHttp.au3> #include <WinHttpConstants.au3> #include <String.au3> Func _FBStart() Local $HOST = "m.facebook.com" Local $hSession = _WinHttpOpen("Mozilla/5.0 (Windows NT 6.1; rv:44.0) Gecko/20100101 Firefox/44.0") If @error Then Return SetError(1, 0, 0) Else Local $HTTP_ConnectFB = _WinHttpConnect($hSession, $HOST, $INTERNET_DEFAULT_HTTPS_PORT) If @error Then Return SetError(2, 0, 0) Else Return $HTTP_ConnectFB EndIf EndIf EndFunc Global $startttttttt = _FBStart() $login = _FBLogin() Func _FBLogin() ;$Email = StringReplace($Email, '@', '%40', 1) $Email = 'yaEmail.@domain.com' $Password = 'p@$$w0rd' $profile_id = 'profile_id' $target_group = 'group_id' If @error Then Return SetError(1, 0, 0) Else Local $HTML = _WinHttpSimpleSSLRequest($startttttttt, "GET", "", Default, Default, Default, 1) If @error Then Return SetError(2, 0, 0) Else ;;;;;;;;;;;FileWrite("m.fb.com.html", $HTML[1]) Local $returnvalue = _StringBetween($HTML[1], 'value="', '"') If @error Then Return SetError(3, 0, 0) Else ;If UBound($returnvalue) < 9 Then ;Return False ;Else Local $value0 = $returnvalue[0] ; Local $value7 = $returnvalue[7] ;0 Local $value8 = $returnvalue[8] ;1 Local $HTML2 = _WinHttpSimpleSSLRequest($startttttttt, "POST", "/login.php?m=m&refsrc=http%3A%2F%2Fm.facebook.com%2F&refid=8", "m.facebook.com", "lsd=&charset_test=" & $value0 & "&version=1&ajax=1&width=1680&pxr=1&gps=1&email=" & $Email & "&pass=" & $Password & "&m_ts=" & $value7 & "&li=" & $value8, Default, 1) If @error Then Return SetError(4, 0, 0) Else FileWrite("logged in.html", $HTML2[1]) Local $get_group = _WinHttpSimpleSSLRequest($startttttttt, "GET", "/groups/" & $target_group, Default, Default, Default, 1) FileWrite('group_page.html',$get_group[1]) $fb_dtsg = StringRegExp($get_group[1], 'name="fb_dtsg" value="(.+?)"', 3) FileWrite('$fb_dtsg.txt',$fb_dtsg[0] & @CRLF) $charset_test = '%E2%82%AC%2C%C2%B4%2C%E2%82%AC%2C%C2%B4%2C%E6%B0%B4%2C%D0%94%2C%D0%84' ;%E2%82%AC%2C%C2%B4%2C%E2%82%AC%2C%C2%B4%2C%E6%B0%B4%2C%D0%94%2C%D0%84 ;'€,´,€,´,水,Д,Є' Local $click_photos_add = _WinHttpSimpleSSLRequest($startttttttt, "POST", "/composer/mbasic/?av=" & $profile_id & "&refid=18", 'https://m.facebook.com/groups/' & $target_group, 'fb_dtsg=' & $fb_dtsg[0] & '&charset_test=' & $charset_test & '&target=' & $target_group & '&c_src=group&cwevent=composer_entry&referrer=group&ctype=inline&cver=amber&rst_icv=&xc_message=&view_photo=Add+Photos', Default, True, 1) FileWrite('after click.html', $click_photos_add) FileWrite('after click[0].html', $click_photos_add[0]) FileWrite('after click[1].html', $click_photos_add[1]) $csid = StringRegExp($click_photos_add[1], 'csid=(.+?)&', 3) $fb_dtsg2 = StringRegExp($click_photos_add[1], 'name="fb_dtsg" value="(.+?)"', 3) FileWrite('$csid.txt', $csid[0] & @CRLF) FileWrite('$fb_dtsg2.txt', $fb_dtsg2[0] & @CRLF) $fileopen = FileOpen('7.jpg', 16); Open in read only mode $fileread = FileRead($fileopen) FileClose($fileopen) ;ConsoleWrite($fileread & @CRLF) Local $boundary = Random(1000000000, 99999999999, 1) MsgBox(0,'',$boundary) Local $sData = '' $sData &= 'Content-Type: multipart/form-data; boundary=--' & $boundary & @CRLF ;$sData &= 'Content-Length:' & '66365' & @CRLF & @CRLF $sData &= '--' & $boundary & @CRLF $sData &= 'Content-Disposition: form-data; name="fb_dtsg"' & @CRLF & @CRLF $sData &= $fb_dtsg2[0] & @CRLF $sData &= '--' & $boundary & @CRLF $sData &= 'Content-Disposition: form-data; name="charset_test"' & @CRLF & @CRLF $sData &= $charset_test & @CRLF $sData &= '--' & $boundary & @CRLF $sData &= 'Content-Disposition: form-data; name="file1"; filename="7.jpg"' & @CRLF $sData &= 'Content-Type: image/jpeg' & @CRLF & @CRLF $sData &= $fileread & @CRLF;;;;;;;;;;;;;;;;;;;;;;;;; $sData &= '--' & $boundary & @CRLF $sData &= 'Content-Disposition: form-data; name="file2"; filename=""' & @CRLF $sData &= 'Content-Type: application/octet-stream' & @CRLF & @CRLF & @CRLF $sData &= '--' & $boundary & @CRLF $sData &= 'Content-Disposition: form-data; name="file3"; filename=""' & @CRLF $sData &= 'Content-Type: application/octet-stream' & @CRLF & @CRLF & @CRLF $sData &= '--' & $boundary & @CRLF $sData &= 'Content-Disposition: form-data; name="add_photo_done"' & @CRLF & @CRLF $sData &= 'Preview' & @CRLF $sData &= '--' & $boundary & @CRLF $sData &= 'Content-Disposition: form-data; name="filter_type"' & @CRLF & @CRLF $sData &= '5' & @CRLF $sData &= '--' & $boundary & @CRLF $sData &= 'Content-Disposition: form-data; name="target_id"' & @CRLF & @CRLF $sData &= $target_group & @CRLF $sData &= '--' & $boundary & @CRLF $sData &= 'Content-Disposition: form-data; name="waterfall_source"' & @CRLF & @CRLF $sData &= 'composer_group' & @CRLF $sData &= '--' & $boundary & @CRLF $sData &= 'Content-Disposition: form-data; name="waterfall_id"' & @CRLF & @CRLF $sData &= $csid[0] & @CRLF $sData &= '--' & $boundary & @CRLF $sData &= 'Content-Disposition: form-data; name="waterfall_app_name"' & @CRLF & @CRLF $sData &= 'web_m_basic' & @CRLF $sData &= '--' & $boundary & '--' & @CRLF ;Local $len = StringLen($sData) Local $sHead = '' $sHead &= 'Host: m.facebook.com' & @CRLF $sHead &= 'User-Agent: Mozilla/5.0 (Windows NT 6.1; rv:44.0) Gecko/20100101 Firefox/44.0' & @CRLF $sHead &= 'Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8' & @CRLF $sHead &= 'Accept-Language: en-US,en;q=0.5' & @CRLF $sHead &= 'Accept-Encoding: gzip, deflate, br' & @CRLF $sHead &= 'DNT: 1' & @CRLF $sHead &= 'Referer: https://m.facebook.com/composer/mbasic/?mnt_query&csid=' & $csid[0] & '&ctype=inline&errcode=0&cwevent=composer_entry&tag_friends_query&filter_type=0&av=' & $profile_id & '&rst_icv&icv&ogi_offset=0&ogi_limit=0&lat&lon&pos&x-acc=0&view_photo&_rdr' & @CRLF $sHead &= 'Connection: keep-alive' & @CRLF $sHead &= 'Content-Type: multipart/form-data; boundary=' & $boundary & @CRLF ;$sHead &= 'Content-Length: 66365' & @CRLF Local $photos_preview = _WinHttpSimpleSSLRequest($startttttttt, "POST", '/composer/mbasic/?csid=' & $csid[0] & '&av=' & $profile_id & '&view_overview', Default, $sData, $sHead, True, 1) FileWrite('preview.html', $photos_preview) FileWrite('preview[0].html', $photos_preview[0]) FileWrite('preview[1].html', $photos_preview[1]) ;Local $get_photos_preview = _WinHttpSimpleSSLRequest($startttttttt, "GET", '/composer/mbasic/?csid=' & $csid[0] & '&view_overview&av=' & $profile_id & '&_rdr', Default, Default, Default, 1) ;FileWrite('get_photos_preview.html', $get_photos_preview) ;FileWrite('get_photos_preview[0].html', $get_photos_preview[0]) ;FileWrite('get_photos_preview[1].html', $get_photos_preview[1]) EndIf ;EndIf EndIf EndIf EndIf EndFunc _FBLogout($startttttttt, $login) Func _FBLogout($FBStart, $FBLogin) Local $FBHome = _WinHttpSimpleSSLRequest($FBStart, 'GET') If @error Then Return SetError(1, 0, 0) Else Local $Logout = StringRegExp($FBHome, '<a class=".+?" href="(/logout.php.+?)">Logout', 3) If @error Then Return SetError(2, 0, 0) Else Local $HTML3 = _WinHttpSimpleSSLRequest($FBStart, 'GET', $Logout[0]) If @error Then Return SetError(3, 0, 0) Else Return 1 EndIf EndIf EndIf ;;;;;;;;;;;FileWrite("logged out.html", $HTML3[1]) EndFunc pls heelp to correct this Link to comment Share on other sites More sharing options...
trancexx Posted February 6, 2016 Share Posted February 6, 2016 Your code looks too complex to me. You should really add few comments so that others (me - for example) can understand what are you trying to do with each step. Things that look obvious to you may not be that obvious to others. Aside from that, why don't you use WinHttp.au3 in more advanced way? The UDF is probably smarter than you think it is. For example, I just used this code to pick a pic from my comp and upload it to a group: expandcollapse popup#include "WinHttp.au3" Global Const $sFB_Email = "yaEmail.@domain.com" ;<- your email here Global Const $sFB_sPassword = "p@$$w0rd" ;<- your password here $sGroupID = "5555555555555555" ; group ID you want to post to $sPic = FileOpenDialog("Choose Pic to post", "", "Image (*.jpg;*.png;*.gif;*.bmp)"); choose a file you want to post If $sPic Then ConsoleWrite(FB_PostPicToGroup($sGroupID, $sPic) & @CRLF) Func FB_PostPicToGroup($sGroupID, $sPic) Local $iSuccess = 0 ; preset output (failure) ; Open session Local $hOpen = _WinHttpOpen() ; Connect Local $hConnect = _WinHttpConnect($hOpen, "https://m.facebook.com/") ; Login first (by filling login form) Local $sRead = _WinHttpSimpleFormFill($hConnect, _ ; connection handle "login.php", _ ; target page "login_form", _ ; form identifier "name:email", $sFB_Email, _ ; first field identifier paired with field data "name:pass", $sFB_sPassword) ; second field identifier paired with data ; Check for errors If Not @error And @extended = $HTTP_STATUS_OK Then ; Navigate to the Group and ask for pic upload Local $aRead = _WinHttpSimpleFormFill($hConnect, _ ; connection handle "/groups/" & $sGroupID, _ ; target page "index:1", _ ; form identifier (by index here, because id or name doesn't exist) "name:view_photo", True, _ ; identify submit control and click it "[RETURN_ARRAY]") ; return array because current URL is needed ; Check for errors If Not @error And @extended = $HTTP_STATUS_OK Then ; Read current URL (go with the flow) Local $aURL = _WinHttpCrackUrl($aRead[2]) If Not @error Then ; check for error ; Upload file $aRead = _WinHttpSimpleFormFill($hConnect, _ ; connection handle $aURL[6] & $aURL[7], _ ; target page Default, _ ; form identifier (default is used for simplicity because it's the only form on that page) "name:file1", $sPic, _ ; form field used for file "[RETURN_ARRAY]") ; return array because current URL is needed ; Check for errors If Not @error And @extended = $HTTP_STATUS_OK Then ; Read current URL now $aURL = _WinHttpCrackUrl($aRead[2]) ; check for error If Not @error Then ; Finally submit the post _WinHttpSimpleFormFill($hConnect, _ ; connection handle $aURL[6] & $aURL[7], _ ; target page Default, _ "name:view_post", True) If Not @error And @extended = $HTTP_STATUS_OK Then $iSuccess = 1 EndIf EndIf EndIf EndIf EndIf ; Close handles _WinHttpCloseHandle($hConnect) _WinHttpCloseHandle($hOpen) ; Bye... Return $iSuccess EndFunc Does it do what you want it to do? ntprohd, ruslanas402 and blackandwhite 3 ♡♡♡ . eMyvnE Link to comment Share on other sites More sharing options...
blackandwhite Posted February 7, 2016 Author Share Posted February 7, 2016 (edited) ma gosh yes yes, it's actually what I was need, also I thought about to use _WinHttpSimpleFormFill, but it was little complicated to me, thaaank youuu ! Edited February 22, 2016 by blackandwhite Link to comment Share on other sites More sharing options...
blackandwhite Posted February 22, 2016 Author Share Posted February 22, 2016 Is there any ways to upload more than 3 files? I'm really don't have any idea how to realize that Link to comment Share on other sites More sharing options...
ruslanas402 Posted September 11, 2016 Share Posted September 11, 2016 On 06/02/2016 at 5:48 PM, trancexx said: Your code looks too complex to me. You should really add few comments so that others (me - for example) can understand what are you trying to do with each step. Things that look obvious to you may not be that obvious to others. Aside from that, why don't you use WinHttp.au3 in more advanced way? The UDF is probably smarter than you think it is. For example, I just used this code to pick a pic from my comp and upload it to a group: expandcollapse popup#include "WinHttp.au3" Global Const $sFB_Email = "yaEmail.@domain.com" ;<- your email here Global Const $sFB_sPassword = "p@$$w0rd" ;<- your password here $sGroupID = "5555555555555555" ; group ID you want to post to $sPic = FileOpenDialog("Choose Pic to post", "", "Image (*.jpg;*.png;*.gif;*.bmp)"); choose a file you want to post If $sPic Then ConsoleWrite(FB_PostPicToGroup($sGroupID, $sPic) & @CRLF) Func FB_PostPicToGroup($sGroupID, $sPic) Local $iSuccess = 0 ; preset output (failure) ; Open session Local $hOpen = _WinHttpOpen() ; Connect Local $hConnect = _WinHttpConnect($hOpen, "https://m.facebook.com/") ; Login first (by filling login form) Local $sRead = _WinHttpSimpleFormFill($hConnect, _ ; connection handle "login.php", _ ; target page "login_form", _ ; form identifier "name:email", $sFB_Email, _ ; first field identifier paired with field data "name:pass", $sFB_sPassword) ; second field identifier paired with data ; Check for errors If Not @error And @extended = $HTTP_STATUS_OK Then ; Navigate to the Group and ask for pic upload Local $aRead = _WinHttpSimpleFormFill($hConnect, _ ; connection handle "/groups/" & $sGroupID, _ ; target page "index:1", _ ; form identifier (by index here, because id or name doesn't exist) "name:view_photo", True, _ ; identify submit control and click it "[RETURN_ARRAY]") ; return array because current URL is needed ; Check for errors If Not @error And @extended = $HTTP_STATUS_OK Then ; Read current URL (go with the flow) Local $aURL = _WinHttpCrackUrl($aRead[2]) If Not @error Then ; check for error ; Upload file $aRead = _WinHttpSimpleFormFill($hConnect, _ ; connection handle $aURL[6] & $aURL[7], _ ; target page Default, _ ; form identifier (default is used for simplicity because it's the only form on that page) "name:file1", $sPic, _ ; form field used for file "[RETURN_ARRAY]") ; return array because current URL is needed ; Check for errors If Not @error And @extended = $HTTP_STATUS_OK Then ; Read current URL now $aURL = _WinHttpCrackUrl($aRead[2]) ; check for error If Not @error Then ; Finally submit the post _WinHttpSimpleFormFill($hConnect, _ ; connection handle $aURL[6] & $aURL[7], _ ; target page Default, _ "name:view_post", True) If Not @error And @extended = $HTTP_STATUS_OK Then $iSuccess = 1 EndIf EndIf EndIf EndIf EndIf ; Close handles _WinHttpCloseHandle($hConnect) _WinHttpCloseHandle($hOpen) ; Bye... Return $iSuccess EndFunc Does it do what you want it to do? So useful I've been making same script for weeks, just without winHttp Could you tell, trancexx where can I input variable to write post as well? Thanks in advance. Link to comment Share on other sites More sharing options...
ntprohd Posted November 15, 2016 Share Posted November 15, 2016 On 7/2/2016 at 0:48 AM, trancexx said: Your code looks too complex to me. You should really add few comments so that others (me - for example) can understand what are you trying to do with each step. Things that look obvious to you may not be that obvious to others. Aside from that, why don't you use WinHttp.au3 in more advanced way? The UDF is probably smarter than you think it is. For example, I just used this code to pick a pic from my comp and upload it to a group: expandcollapse popup#include "WinHttp.au3" Global Const $sFB_Email = "yaEmail.@domain.com" ;<- your email here Global Const $sFB_sPassword = "p@$$w0rd" ;<- your password here $sGroupID = "5555555555555555" ; group ID you want to post to $sPic = FileOpenDialog("Choose Pic to post", "", "Image (*.jpg;*.png;*.gif;*.bmp)"); choose a file you want to post If $sPic Then ConsoleWrite(FB_PostPicToGroup($sGroupID, $sPic) & @CRLF) Func FB_PostPicToGroup($sGroupID, $sPic) Local $iSuccess = 0 ; preset output (failure) ; Open session Local $hOpen = _WinHttpOpen() ; Connect Local $hConnect = _WinHttpConnect($hOpen, "https://m.facebook.com/") ; Login first (by filling login form) Local $sRead = _WinHttpSimpleFormFill($hConnect, _ ; connection handle "login.php", _ ; target page "login_form", _ ; form identifier "name:email", $sFB_Email, _ ; first field identifier paired with field data "name:pass", $sFB_sPassword) ; second field identifier paired with data ; Check for errors If Not @error And @extended = $HTTP_STATUS_OK Then ; Navigate to the Group and ask for pic upload Local $aRead = _WinHttpSimpleFormFill($hConnect, _ ; connection handle "/groups/" & $sGroupID, _ ; target page "index:1", _ ; form identifier (by index here, because id or name doesn't exist) "name:view_photo", True, _ ; identify submit control and click it "[RETURN_ARRAY]") ; return array because current URL is needed ; Check for errors If Not @error And @extended = $HTTP_STATUS_OK Then ; Read current URL (go with the flow) Local $aURL = _WinHttpCrackUrl($aRead[2]) If Not @error Then ; check for error ; Upload file $aRead = _WinHttpSimpleFormFill($hConnect, _ ; connection handle $aURL[6] & $aURL[7], _ ; target page Default, _ ; form identifier (default is used for simplicity because it's the only form on that page) "name:file1", $sPic, _ ; form field used for file "[RETURN_ARRAY]") ; return array because current URL is needed ; Check for errors If Not @error And @extended = $HTTP_STATUS_OK Then ; Read current URL now $aURL = _WinHttpCrackUrl($aRead[2]) ; check for error If Not @error Then ; Finally submit the post _WinHttpSimpleFormFill($hConnect, _ ; connection handle $aURL[6] & $aURL[7], _ ; target page Default, _ "name:view_post", True) If Not @error And @extended = $HTTP_STATUS_OK Then $iSuccess = 1 EndIf EndIf EndIf EndIf EndIf ; Close handles _WinHttpCloseHandle($hConnect) _WinHttpCloseHandle($hOpen) ; Bye... Return $iSuccess EndFunc Does it do what you want it to do? His great answer but how can I upload a lot of pictures in the same article and are accompanied by the text of that article Link to comment Share on other sites More sharing options...
pablodalma Posted May 2, 2017 Share Posted May 2, 2017 I'm trying to run the script On 2016-2-6 at 2:48 PM, trancexx said: Your code looks too complex to me. You should really add few comments so that others (me - for example) can understand what are you trying to do with each step. Things that look obvious to you may not be that obvious to others. Aside from that, why don't you use WinHttp.au3 in more advanced way? The UDF is probably smarter than you think it is. For example, I just used this code to pick a pic from my comp and upload it to a group: expandcollapse popup#include "WinHttp.au3" Global Const $sFB_Email = "yaEmail.@domain.com" ;<- your email here Global Const $sFB_sPassword = "p@$$w0rd" ;<- your password here $sGroupID = "5555555555555555" ; group ID you want to post to $sPic = FileOpenDialog("Choose Pic to post", "", "Image (*.jpg;*.png;*.gif;*.bmp)"); choose a file you want to post If $sPic Then ConsoleWrite(FB_PostPicToGroup($sGroupID, $sPic) & @CRLF) Func FB_PostPicToGroup($sGroupID, $sPic) Local $iSuccess = 0 ; preset output (failure) ; Open session Local $hOpen = _WinHttpOpen() ; Connect Local $hConnect = _WinHttpConnect($hOpen, "https://m.facebook.com/") ; Login first (by filling login form) Local $sRead = _WinHttpSimpleFormFill($hConnect, _ ; connection handle "login.php", _ ; target page "login_form", _ ; form identifier "name:email", $sFB_Email, _ ; first field identifier paired with field data "name:pass", $sFB_sPassword) ; second field identifier paired with data ; Check for errors If Not @error And @extended = $HTTP_STATUS_OK Then ; Navigate to the Group and ask for pic upload Local $aRead = _WinHttpSimpleFormFill($hConnect, _ ; connection handle "/groups/" & $sGroupID, _ ; target page "index:1", _ ; form identifier (by index here, because id or name doesn't exist) "name:view_photo", True, _ ; identify submit control and click it "[RETURN_ARRAY]") ; return array because current URL is needed ; Check for errors If Not @error And @extended = $HTTP_STATUS_OK Then ; Read current URL (go with the flow) Local $aURL = _WinHttpCrackUrl($aRead[2]) If Not @error Then ; check for error ; Upload file $aRead = _WinHttpSimpleFormFill($hConnect, _ ; connection handle $aURL[6] & $aURL[7], _ ; target page Default, _ ; form identifier (default is used for simplicity because it's the only form on that page) "name:file1", $sPic, _ ; form field used for file "[RETURN_ARRAY]") ; return array because current URL is needed ; Check for errors If Not @error And @extended = $HTTP_STATUS_OK Then ; Read current URL now $aURL = _WinHttpCrackUrl($aRead[2]) ; check for error If Not @error Then ; Finally submit the post _WinHttpSimpleFormFill($hConnect, _ ; connection handle $aURL[6] & $aURL[7], _ ; target page Default, _ "name:view_post", True) If Not @error And @extended = $HTTP_STATUS_OK Then $iSuccess = 1 EndIf EndIf EndIf EndIf EndIf ; Close handles _WinHttpCloseHandle($hConnect) _WinHttpCloseHandle($hOpen) ; Bye... Return $iSuccess EndFunc Does it do what you want it to do? I'm trying to run this script and it asks me for WinHttp.au3 file. I looked for it in internet and then it asks me for WinHttpConstants.au3 file. I downloaded the last AutoIt version v3.3.14.2 to run it. Which version or package do I need to download for this script to run and not ask me files which are included and which dont exist in version v3.3.14.2 ? Link to comment Share on other sites More sharing options...
BrewManNH Posted May 2, 2017 Share Posted May 2, 2017 You need to search for it in the Examples section of this forum, it's not a standard include with AutoIt. If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag GudeHow to ask questions the smart way! I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from. Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays. - ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script. - Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label. - _FileGetProperty - Retrieve the properties of a file - SciTE Toolbar - A toolbar demo for use with the SciTE editor - GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI. - Latin Square password generator Link to comment Share on other sites More sharing options...
pablodalma Posted May 3, 2017 Share Posted May 3, 2017 (edited) 19 hours ago, BrewManNH said: You need to search for it in the Examples section of this forum, it's not a standard include with AutoIt. I solved it (thanks to help from another programmer) but now the script only asks for an image and then nothing happens, no error of any kind, but no image upload and no result. Any suggestion to debug it? Edited May 3, 2017 by pablodalma Link to comment Share on other sites More sharing options...
El-Masry Posted August 3, 2019 Share Posted August 3, 2019 On 2/6/2016 at 7:48 PM, trancexx said: Your code looks too complex to me. You should really add few comments so that others (me - for example) can understand what are you trying to do with each step. Things that look obvious to you may not be that obvious to others. Aside from that, why don't you use WinHttp.au3 in more advanced way? The UDF is probably smarter than you think it is. For example, I just used this code to pick a pic from my comp and upload it to a group: expandcollapse popup#include "WinHttp.au3" Global Const $sFB_Email = "yaEmail.@domain.com" ;<- your email here Global Const $sFB_sPassword = "p@$$w0rd" ;<- your password here $sGroupID = "5555555555555555" ; group ID you want to post to $sPic = FileOpenDialog("Choose Pic to post", "", "Image (*.jpg;*.png;*.gif;*.bmp)"); choose a file you want to post If $sPic Then ConsoleWrite(FB_PostPicToGroup($sGroupID, $sPic) & @CRLF) Func FB_PostPicToGroup($sGroupID, $sPic) Local $iSuccess = 0 ; preset output (failure) ; Open session Local $hOpen = _WinHttpOpen() ; Connect Local $hConnect = _WinHttpConnect($hOpen, "https://m.facebook.com/") ; Login first (by filling login form) Local $sRead = _WinHttpSimpleFormFill($hConnect, _ ; connection handle "login.php", _ ; target page "login_form", _ ; form identifier "name:email", $sFB_Email, _ ; first field identifier paired with field data "name:pass", $sFB_sPassword) ; second field identifier paired with data ; Check for errors If Not @error And @extended = $HTTP_STATUS_OK Then ; Navigate to the Group and ask for pic upload Local $aRead = _WinHttpSimpleFormFill($hConnect, _ ; connection handle "/groups/" & $sGroupID, _ ; target page "index:1", _ ; form identifier (by index here, because id or name doesn't exist) "name:view_photo", True, _ ; identify submit control and click it "[RETURN_ARRAY]") ; return array because current URL is needed ; Check for errors If Not @error And @extended = $HTTP_STATUS_OK Then ; Read current URL (go with the flow) Local $aURL = _WinHttpCrackUrl($aRead[2]) If Not @error Then ; check for error ; Upload file $aRead = _WinHttpSimpleFormFill($hConnect, _ ; connection handle $aURL[6] & $aURL[7], _ ; target page Default, _ ; form identifier (default is used for simplicity because it's the only form on that page) "name:file1", $sPic, _ ; form field used for file "[RETURN_ARRAY]") ; return array because current URL is needed ; Check for errors If Not @error And @extended = $HTTP_STATUS_OK Then ; Read current URL now $aURL = _WinHttpCrackUrl($aRead[2]) ; check for error If Not @error Then ; Finally submit the post _WinHttpSimpleFormFill($hConnect, _ ; connection handle $aURL[6] & $aURL[7], _ ; target page Default, _ "name:view_post", True) If Not @error And @extended = $HTTP_STATUS_OK Then $iSuccess = 1 EndIf EndIf EndIf EndIf EndIf ; Close handles _WinHttpCloseHandle($hConnect) _WinHttpCloseHandle($hOpen) ; Bye... Return $iSuccess EndFunc Does it do what you want it to do? thanks ..this code works how can I add text with the image in post ?? Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now