jaberwacky Posted July 21, 2015 Share Posted July 21, 2015 I could help you with the rest but I don't want to take that "Made it Ma! Top of the world!" feeling away from you.I feel I've put all that I can into this. If you want to help me out then I won't feel like a total loser. If you want to help me then I will gladly accept your help. Will you help with the rest? I have nothing to pay you except for kindness. Helpful Posts and Websites: AutoIt3 Variables and Function Parameters MHz | AutoIt Wiki | Using the GUIToolTip UDF BrewManNH | Can't find what you're looking for on the Forum? Link to comment Share on other sites More sharing options...
trancexx Posted July 22, 2015 Author Share Posted July 22, 2015 I feel I've put all that I can into this. If you want to help me out then I won't feel like a total loser. If you want to help me then I will gladly accept your help. Will you help with the rest? I have nothing to pay you except for kindness.I don't get that last sentence. What does it mean?Just add errors checks and missing function:Func _imgur_uploadur(Const $image_file) Local $hFile = FileOpen($image_file, 16) Local $bData = FileRead($hFile) FileClose($hFile) Local Const $sClientID = "3fda9b4a8bc150c" ; your client-id Local Const $hOpen = _WinHttpOpen() _WinHttpSetTimeouts($hOpen, 10000, 60000, 90000, 90000) ; see, you can do it here too Local Const $hConnect = _WinHttpConnect($hOpen, "https://api.imgur.com") Local $sReceivedData = _WinHttpSimpleSSLRequest($hConnect, "POST", "/3/upload.xml", Default, "image=" & Base64Encode($bData), "Content-Type: application/x-www-form-urlencoded" & @CRLF & "Authorization: Client-ID " & $sClientID) _WinHttpCloseHandle($hConnect) _WinHttpCloseHandle($hOpen) Return $sReceivedData EndFuncThat's the same thing as that VB example that you showed as far as HTTP goes. jaberwacky 1 ♡♡♡ . eMyvnE Link to comment Share on other sites More sharing options...
jaberwacky Posted July 22, 2015 Share Posted July 22, 2015 It means if you want to help me then I can't pay you in money. All I have is kindness. Do you accept kindness rain checks? XDBut seriously, thank you. Two good days in a row for the internet. Helpful Posts and Websites: AutoIt3 Variables and Function Parameters MHz | AutoIt Wiki | Using the GUIToolTip UDF BrewManNH | Can't find what you're looking for on the Forum? Link to comment Share on other sites More sharing options...
jaberwacky Posted July 22, 2015 Share Posted July 22, 2015 (edited) Function _WinHttpSimpleSendRequest in function _WinHttpSimpleSendSSLRequest throws an error 3. I don't have nor could I figure out the dll. Any hints on what that means? Edited July 22, 2015 by jaberwacky Helpful Posts and Websites: AutoIt3 Variables and Function Parameters MHz | AutoIt Wiki | Using the GUIToolTip UDF BrewManNH | Can't find what you're looking for on the Forum? Link to comment Share on other sites More sharing options...
trancexx Posted July 22, 2015 Author Share Posted July 22, 2015 (edited) It means if you want to help me then I can't pay you in money. All I have is kindness. Do you accept kindness rain checks? XDBut seriously, thank you. Two good days in a row for the internet. I suspected it'd be something like that. My English level made me have doubts though. If someone says: "I have nothing to pay you except for kindness." I read that as if they owe me nothing for anything I've done except for being kind, which is kinda opposite of what you said it really means. Silly me, right?I have nothing to pay you with except ... - would make me have no doubts. Edited July 22, 2015 by trancexx ♡♡♡ . eMyvnE Link to comment Share on other sites More sharing options...
jaberwacky Posted July 22, 2015 Share Posted July 22, 2015 Nah, it's not silly. Your english level is great. Now if I could ever just get up on your autoit level then that would be something. mLipok 1 Helpful Posts and Websites: AutoIt3 Variables and Function Parameters MHz | AutoIt Wiki | Using the GUIToolTip UDF BrewManNH | Can't find what you're looking for on the Forum? Link to comment Share on other sites More sharing options...
jchd Posted July 22, 2015 Share Posted July 22, 2015 http://www.songtexte.com/songtext/news-from-babel/banknote-5bc03b00.html jaberwacky 1 This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe hereRegExp tutorial: enough to get startedPCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta. SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt) Link to comment Share on other sites More sharing options...
jaberwacky Posted July 23, 2015 Share Posted July 23, 2015 trancexx, which Base64Encode function are you using? Ward's? Helpful Posts and Websites: AutoIt3 Variables and Function Parameters MHz | AutoIt Wiki | Using the GUIToolTip UDF BrewManNH | Can't find what you're looking for on the Forum? Link to comment Share on other sites More sharing options...
trancexx Posted July 23, 2015 Author Share Posted July 23, 2015 (edited) Why? Base64 is Base64.Func Base64Encode($vInput) Local Const $CRYPT_STRING_BASE64 = 0x00000001 $vInput = Binary($vInput) Local $tInput = DllStructCreate("byte[" & BinaryLen($vInput) & "]") DllStructSetData($tInput, 1, $vInput) Local $aCall = DllCall("Crypt32.dll", "bool", "CryptBinaryToStringA", _ "struct*", $tInput, _ "dword", DllStructGetSize($tInput), _ "dword", $CRYPT_STRING_BASE64, _ "ptr", 0, _ "dword*", 0) If @error Or Not $aCall[0] Then Return SetError(1, 0, "") ; error calculating the length of the needed buffer Local $tOut = DllStructCreate("char[" & $aCall[5] & "]") $aCall = DllCall("Crypt32.dll", "int", "CryptBinaryToStringA", _ "struct*", $tInput, _ "dword", DllStructGetSize($tInput), _ "dword", $CRYPT_STRING_BASE64, _ "struct*", $tOut, _ "dword*", DllStructGetSize($tOut)) If @error Or Not $aCall[0] Then Return SetError(2, 0, ""); error encoding Return DllStructGetData($tOut, 1) EndFunc Edited July 23, 2015 by trancexx ♡♡♡ . eMyvnE Link to comment Share on other sites More sharing options...
jaberwacky Posted July 23, 2015 Share Posted July 23, 2015 You're right. It didn't make a difference. Helpful Posts and Websites: AutoIt3 Variables and Function Parameters MHz | AutoIt Wiki | Using the GUIToolTip UDF BrewManNH | Can't find what you're looking for on the Forum? Link to comment Share on other sites More sharing options...
trancexx Posted July 23, 2015 Author Share Posted July 23, 2015 You have problem with function for every file or just some specific? ♡♡♡ . eMyvnE Link to comment Share on other sites More sharing options...
jaberwacky Posted July 23, 2015 Share Posted July 23, 2015 Every file. I think it connects to the server because this is the message I get:<?xml version="1.0" encoding="utf-8"?> <data type="array" success="0" status="400"><error>Image format not supported, or image is corrupt.</error><request>/3/upload.xml</request><method>POST</method></data> Helpful Posts and Websites: AutoIt3 Variables and Function Parameters MHz | AutoIt Wiki | Using the GUIToolTip UDF BrewManNH | Can't find what you're looking for on the Forum? Link to comment Share on other sites More sharing options...
jaberwacky Posted July 23, 2015 Share Posted July 23, 2015 Wait a second. It worked. Just now. humph. Imagine that. Will need more testing. Helpful Posts and Websites: AutoIt3 Variables and Function Parameters MHz | AutoIt Wiki | Using the GUIToolTip UDF BrewManNH | Can't find what you're looking for on the Forum? Link to comment Share on other sites More sharing options...
trancexx Posted July 23, 2015 Author Share Posted July 23, 2015 Don't use base64 method. They aren't handling it well. ♡♡♡ . eMyvnE Link to comment Share on other sites More sharing options...
jaberwacky Posted July 23, 2015 Share Posted July 23, 2015 No, scratch that. I must have reverted to using your other function with the _WinHttpSimpleFormFill. Which would be great but I don't see a way to get progress updates. Helpful Posts and Websites: AutoIt3 Variables and Function Parameters MHz | AutoIt Wiki | Using the GUIToolTip UDF BrewManNH | Can't find what you're looking for on the Forum? Link to comment Share on other sites More sharing options...
jaberwacky Posted July 23, 2015 Share Posted July 23, 2015 Don't use base64 method. They aren't handling it well.Same error message. Helpful Posts and Websites: AutoIt3 Variables and Function Parameters MHz | AutoIt Wiki | Using the GUIToolTip UDF BrewManNH | Can't find what you're looking for on the Forum? Link to comment Share on other sites More sharing options...
trancexx Posted July 23, 2015 Author Share Posted July 23, 2015 No, scratch that. I must have reverted to using your other function with the _WinHttpSimpleFormFill. Which would be great but I don't see a way to get progress updates.What progress updates?How does base64 method offers ability to do that? ♡♡♡ . eMyvnE Link to comment Share on other sites More sharing options...
jaberwacky Posted July 23, 2015 Share Posted July 23, 2015 I meant, well, I was talking about two different things.So, the error message that I posted earlier is still there. The progress updates, I meant that using the WinHttpSimpleFormFill method doesn't allow me to get progress updates from the imgur server. Other than that the function uploads just fine! Helpful Posts and Websites: AutoIt3 Variables and Function Parameters MHz | AutoIt Wiki | Using the GUIToolTip UDF BrewManNH | Can't find what you're looking for on the Forum? Link to comment Share on other sites More sharing options...
trancexx Posted July 23, 2015 Author Share Posted July 23, 2015 But you never get progress updates from the server. You've lost me now.If you want detailed report of the whole process there is option to use callback function. Like this maybe:expandcollapse popup#include "WinHttp.au3" Const $sClientID = "555555555555555" ; your client-id Const $sAddress = "https://api.imgur.com/3/upload.xml" ; the address of the target (https or http, makes no difference - handled automatically) Const $sForm = _ '<form action="' & $sAddress & '" method="post" enctype="multipart/form-data">' & _ ' <input type="file" name="image"/>' & _ ; '</form>' $sFileToUpload = FileOpenDialog("Open", "", "Images (*.jpg;*.gif;*.png;*.bmp)") ; Initialize and get session handle $hOpen = _WinHttpOpen() Const $hWINHTTP_STATUS_CALLBACK = DllCallbackRegister(__WINHTTP_STATUS_CALLBACK, "none", "handle;dword_ptr;dword;ptr;dword") ; Associate callback function with session _WinHttpSetStatusCallback($hOpen, $hWINHTTP_STATUS_CALLBACK) $hConnect = $sForm ; will pass form as string so this is for coding correctness because $hConnect goes in byref ; Fill form $sReturned = _WinHttpSimpleFormFill($hConnect, $hOpen, _ Default, _ "name:image", $sFileToUpload, _ "Authorization: Client-ID " & $sClientID) If @error Then MsgBox(4096, "Error", "Error number = " & @error) Else ConsoleWrite(@CRLF & $sReturned & @CRLF) EndIf ; Close handles _WinHttpCloseHandle($hConnect) _WinHttpCloseHandle($hOpen) DllCallbackFree($hWINHTTP_STATUS_CALLBACK) ; Define callback function Func __WINHTTP_STATUS_CALLBACK($hInternet, $iContext, $iInternetStatus, $pStatusInformation, $iStatusInformationLength) #forceref $hInternet, $iContext, $pStatusInformation, $iStatusInformationLength ConsoleWrite("--> ") ; Interpret the status Local $sStatus Switch $iInternetStatus Case $WINHTTP_CALLBACK_STATUS_CLOSING_CONNECTION $sStatus = "Closing the connection to the server" Case $WINHTTP_CALLBACK_STATUS_CONNECTED_TO_SERVER $sStatus = "Successfully connected to the server." Case $WINHTTP_CALLBACK_STATUS_CONNECTING_TO_SERVER $sStatus = "Connecting to the server." Case $WINHTTP_CALLBACK_STATUS_CONNECTION_CLOSED $sStatus = "Successfully closed the connection to the server." Case $WINHTTP_CALLBACK_STATUS_DATA_AVAILABLE $sStatus = "Data is available to be retrieved with WinHttpReadData." Case $WINHTTP_CALLBACK_STATUS_HANDLE_CREATED $sStatus = "An HINTERNET handle has been created." Case $WINHTTP_CALLBACK_STATUS_HANDLE_CLOSING $sStatus = "Handle has been terminated." Case $WINHTTP_CALLBACK_STATUS_HEADERS_AVAILABLE $sStatus = "The response header has been received and is available with WinHttpQueryHeaders." Case $WINHTTP_CALLBACK_STATUS_INTERMEDIATE_RESPONSE $sStatus = "Received an intermediate (100 level) status code message from the server." Case $WINHTTP_CALLBACK_STATUS_NAME_RESOLVED $sStatus = "Successfully found the IP address of the server." Case $WINHTTP_CALLBACK_STATUS_READ_COMPLETE $sStatus = "Data was successfully read from the server." Case $WINHTTP_CALLBACK_STATUS_RECEIVING_RESPONSE $sStatus = "Waiting for the server to respond to a request." Case $WINHTTP_CALLBACK_STATUS_REDIRECT $sStatus = "An HTTP request is about to automatically redirect the request." Case $WINHTTP_CALLBACK_STATUS_REQUEST_ERROR $sStatus = "An error occurred while sending an HTTP request." Case $WINHTTP_CALLBACK_STATUS_REQUEST_SENT $sStatus = "Successfully sent the information request to the server." Case $WINHTTP_CALLBACK_STATUS_RESOLVING_NAME $sStatus = "Looking up the IP address of a server name." Case $WINHTTP_CALLBACK_STATUS_RESPONSE_RECEIVED $sStatus = "Successfully received a response from the server." Case $WINHTTP_CALLBACK_STATUS_SECURE_FAILURE $sStatus = "One or more errors were encountered while retrieving a Secure Sockets Layer (SSL) certificate from the server." Case $WINHTTP_CALLBACK_STATUS_SENDING_REQUEST $sStatus = "Sending the information request to the server." Case $WINHTTP_CALLBACK_STATUS_SENDREQUEST_COMPLETE $sStatus = "The request completed successfully." Case $WINHTTP_CALLBACK_STATUS_WRITE_COMPLETE $sStatus = "Data was successfully written to the server." EndSwitch ; Print it ConsoleWrite($sStatus & @CRLF) EndFunc mLipok 1 ♡♡♡ . eMyvnE Link to comment Share on other sites More sharing options...
jaberwacky Posted July 23, 2015 Share Posted July 23, 2015 Thanks for that info.I think I will just stick with your _WinHttpSimpleFormFill example. You know I'd do this on my own if I could. I hate to be a bother. Thank you for what you've provided. I can't thank you enough! Helpful Posts and Websites: AutoIt3 Variables and Function Parameters MHz | AutoIt Wiki | Using the GUIToolTip UDF BrewManNH | Can't find what you're looking for on the Forum? 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