Simucal Posted February 23, 2007 Share Posted February 23, 2007 I'm attempting to write a script to post images to www.imageshack.us . I have applied for and received a developer key from them which gives me permission to use their XML API. While just playing around with idea of submitting images to their website through a script I used the IE udf's to come up with a quick hack: #include <IE.au3> Global $sFilename = "C:\test.jpg" $oIE = _IECreate("www.imageshack.us") $oForm = _IEFormGetObjByName($oIE, "upform") $oInputFile = _IEFormElementGetObjByName($oForm, "fileupload") $oSubmit = _IEFormElementGetObjByName($oForm, "butan") _IEAction($oInputFile, "focus") Send($sFilename) _IEAction($oSubmit, "click")oÝ÷ Øz0z÷«»aȬoø¡£0Èm¢Ë+b¨°(ºWeG¢ë¶8Êç-1%Ì/eÌ,tÓ>Ú¢{-®ç-j,¶g¬±¨Â+a¶¦è¦¸µè¦jWÛ.nhÔáËzk%Gç!ÞzW j{l¢[í¢g®ùbþéRyªÜ)àjº.Ú'¶§z×è®)ߢ¹¶*'¢{ays4Ï¡¸ÞrÒ!j÷¦i×+&y¨«mzjmjÜ!jÒ7ökkÊ)à¶hjëh×6Func _UploadImage($sFilepath) $oXMLHTTP = ObjCreate("MSXML2.XMLHTTP") $oXMLDOC = ObjCreate("MSXML.DOMDocument") $oXMLHTTP.Open("POST", "http://www.imageshack.us/index.php", "false") ; Set http verb to post, url, and asynchronous mode to false $oXMLHTTP.setRequestHeader("Content-Type", "multipart/form-data;") ;some how include image binary data in post here ? $oXMLHTTP.Send("fileupload="&$sFilePath&'&xml="yes"') ; I dont believe I need to submit the filepath, but the actual file data itself $sData = $oXMLDoc.load($oXMLHTTP.responseXML.xml) If Not $sData Then MsgBox(0, "Error", "Error Loading XML from HTTP") EndIf EndFunc I knew this wouldn't work even when I wrote it, but I wanted to show I've made some attempt. I need to some how submit the binary data of the image in my post request. If you go to the developer website of imageshack it says this: Regular Uploading Send the following variables via POST to http://www.imageshack.us/index.php * fileupload; (the image) * xml = "yes"; (specifies the return of XML) * cookie; (registration code, optional) Assuming the upload completes without problems, the xml data may be manipulated as necessary. To show the user the results of his or her upload, redirect the user to <done_page>. Website I have found that seem somewhat related to this topic: Post binary data to website using HTTP Post Wikipedia XMLHTTPRequest AutoIt Scripts:Aimbot: Proof of Concept - PixelSearching Aimbot with several search/autoshoot/lock-on techniques.Sliding Toolbar - Add a nice Sliding Toolbar to your next script. Click the link to see an animation of it in action!FontInfo UDF - Get list of system fonts, or search to see if a particular font is installed.Get Extended Property UDF - Retrieve a files extended properties (e.g., video/image dimensions, file version, bitrate of song/video, etc) Link to comment Share on other sites More sharing options...
Simucal Posted February 23, 2007 Author Share Posted February 23, 2007 I just saw the COM support section, perhaps this should of gone there. AutoIt Scripts:Aimbot: Proof of Concept - PixelSearching Aimbot with several search/autoshoot/lock-on techniques.Sliding Toolbar - Add a nice Sliding Toolbar to your next script. Click the link to see an animation of it in action!FontInfo UDF - Get list of system fonts, or search to see if a particular font is installed.Get Extended Property UDF - Retrieve a files extended properties (e.g., video/image dimensions, file version, bitrate of song/video, etc) Link to comment Share on other sites More sharing options...
Simucal Posted February 26, 2007 Author Share Posted February 26, 2007 (edited) Ok.. so I'm making a little progress. I have since figured out how to stream the binary data of the image in the post message (using the ADODB object). However, I am not exactly sure how to pass the variables that imageshack mentioned they needed (fileupload and xml="yes"). Can ANYONE look at what I've done here and give me some pointers? Func _UploadImage($sFilepath) $oXMLHTTP = ObjCreate("MSXML2.XMLHTTP") $oXMLDOC = ObjCreate("MSXML.DOMDocument") ; for later reading the XML data from the upload $oAdoStream = ObjCreate("ADODB.Stream") ; for streaming the image in the post message $oAdoStream.Mode = 3 ; Set read/write $oAdoStream.Type = 1 ; Type Binary $oAdoStream.Open() $oAdoStream.LoadFromFile($sFilePath) $oXMLHTTP.Open("POST", 'http://www.imageshack.us/index.php', "false") ; Set http verb to post, url, and asynchronous mode to false $oXMLHTTP.setRequestHeader("Content-Type", "multipart/form-data;") ;$oXMLHTTP.setRequestHeader("Content-Length", $oAdoStream.Size) $oXMLHTTP.Send('fileupload="'&$oAdoStream.Read($oAdoStream.Size)&'"&xml="yes"') ; Pretty sure this is how I should stream the data of the image, but am I'm not passing the variables right. ConsoleWrite("Response Text: "&$oXMLHTTP.responseText) $sData = $oXMLDoc.load($oXMLHTTP.responseXML.xml) If Not $sData Then MsgBox(0, "Error", "Error Loading XML from HTTP") EndIf EndFunc Edited February 26, 2007 by Simucal AutoIt Scripts:Aimbot: Proof of Concept - PixelSearching Aimbot with several search/autoshoot/lock-on techniques.Sliding Toolbar - Add a nice Sliding Toolbar to your next script. Click the link to see an animation of it in action!FontInfo UDF - Get list of system fonts, or search to see if a particular font is installed.Get Extended Property UDF - Retrieve a files extended properties (e.g., video/image dimensions, file version, bitrate of song/video, etc) Link to comment Share on other sites More sharing options...
ptrex Posted February 27, 2007 Share Posted February 27, 2007 (edited) @SimucalMaybe this can help you out.ADODB Binary file streamregards,ptrex Edited February 27, 2007 by ptrex Contributions :Firewall Log Analyzer for XP - Creating COM objects without a need of DLL's - UPnP support in AU3Crystal Reports Viewer - PDFCreator in AutoIT - Duplicate File FinderSQLite3 Database functionality - USB Monitoring - Reading Excel using SQLRun Au3 as a Windows Service - File Monitor - Embedded Flash PlayerDynamic Functions - Control Panel Applets - Digital Signing Code - Excel Grid In AutoIT - Constants for Special Folders in WindowsRead data from Any Windows Edit Control - SOAP and Web Services in AutoIT - Barcode Printing Using PS - AU3 on LightTD WebserverMS LogParser SQL Engine in AutoIT - ImageMagick Image Processing - Converter @ Dec - Hex - Bin -Email Address Encoder - MSI Editor - SNMP - MIB ProtocolFinancial Functions UDF - Set ACL Permissions - Syntax HighLighter for AU3ADOR.RecordSet approach - Real OCR - HTTP Disk - PDF Reader Personal Worldclock - MS Indexing Engine - Printing ControlsGuiListView - Navigation (break the 4000 Limit barrier) - Registration Free COM DLL Distribution - Update - WinRM SMART Analysis - COM Object Browser - Excel PivotTable Object - VLC Media Player - Windows LogOnOff Gui -Extract Data from Outlook to Word & Excel - Analyze Event ID 4226 - DotNet Compiler Wrapper - Powershell_COM - New Link to comment Share on other sites More sharing options...
zizou Posted April 24, 2007 Share Posted April 24, 2007 Little Tips : Don't use "False" to Open an URL for an async mode, but -1 , like this : $oXMLHTTP.Open("POST", 'http://www.imageshack.us/index.php', -1) ; it works as async request, so you could use AdlibEnable to update a progressbar when receiving data instead of : $oXMLHTTP.Open("POST", 'http://www.imageshack.us/index.php', "false") ; it don't work as async request 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