faustf Posted September 18, 2019 Share Posted September 18, 2019 hi guys i want interact with my binance account for control if my trade go good or not and close it if not , i try to create something like this but not understund if work good because i am not good for use http request anyone can help me??? thankz expandcollapse popup#cs ---------------------------------------------------------------------------- AutoIt Version: 3.3.14.5 Author: myName Script Function: Template AutoIt script. #ce ---------------------------------------------------------------------------- ; Script Start - Add your code below here #include <Crypt.au3> #include <Date.au3> #include <Array.au3> #include <string.au3> #include <MsgBoxConstants.au3> #include <Timers.au3> #include <String.au3> $timeStamp = _Timer_Init() ConsoleWrite("TimeStamp >> " & $timeStamp & @CRLF) __AccountInfo() Func __AccountInfo() ; https://github.com/binance-exchange/binance-official-api-docs/blob/master/rest-api.md site with information on Binance API calls $accessKey = IniRead (@ScriptDir & "\BinCode.ini","CODE","acceskey","") $secretKey = IniRead (@ScriptDir & "\BinCode.ini","CODE","secretkey","") $param = 'recvWindow=20000×tamp=' & $timeStamp ; $BinarySignature = HMAC($secretKey, $param) $BinarySignature = _Crypt_HashData($secretKey&$param,$CALG_SHA_256) ;$signature = _Base64Encode($BinarySignature) ;Encode signature $signature = _StringToHex($BinarySignature) ;ConsoleWrite(">> Signature >> " & $signature & @CRLF) $request = $param & '&signature=' & $signature ;ConsoleWrite(">> $request >> " & $request & @CRLF) $oHTTP = ObjCreate("winhttp.winhttprequest.5.1") $oHTTP.Open("GET", "https://api.binance.com/api/v3/account", False) $oHTTP.SetRequestHeader("User-Agent", 'Mozilla/5.0 (Windows NT 10.0; WOW64) WinHttp/1.6.3.9 (WinHTTP/5.1) like Gecko') $oHTTP.SetRequestHeader("X-MBX-APIKEY", $accessKey) $oHTTP.Send($request) $oHTTP.Send() $oReceived = $oHTTP.ResponseText $oStatusCode = $oHTTP.Status If $oStatusCode <> 200 Then MsgBox(4096, "Response code", $oStatusCode) EndIf ConsoleWrite("Response Text >> " & $oReceived & @CRLF & @CRLF) EndFunc ;==>__BinanceAPI #cs Func sha256($message) Return _Crypt_HashData($message,$CALG_SHA_256) EndFunc Func HMAC($key, $message, $hash="sha256") Local $blocksize = 64 Local $a_opad[$blocksize], $a_ipad[$blocksize] Local Const $oconst = 0x5C, $iconst = 0x36 Local $opad = Binary(''), $ipad = Binary('') $key = Binary($key) If BinaryLen($key) > $blocksize Then $key = Call($hash, $key) For $i = 1 To BinaryLen($key) $a_ipad[$i-1] = Number(BinaryMid($key, $i, 1)) $a_opad[$i-1] = Number(BinaryMid($key, $i, 1)) Next For $i = 0 To $blocksize - 1 $a_opad[$i] = BitXOR($a_opad[$i], $oconst) $a_ipad[$i] = BitXOR($a_ipad[$i], $iconst) Next For $i = 0 To $blocksize - 1 $ipad &= Binary('0x' & Hex($a_ipad[$i],2)) $opad &= Binary('0x' & Hex($a_opad[$i],2)) Next Return Call($hash, $opad & Call($hash, $ipad & Binary($message))) EndFunc #ce Link to comment Share on other sites More sharing options...
Jefrey Posted October 1, 2019 Share Posted October 1, 2019 What exactly is the problem you are facing? My stuff Spoiler My UDFs _AuThread multithreading emulation for AutoIt · _ExtInputBox an inputbox with multiple inputs and more features · forceUTF8 fix strings encoding without knowing its original charset · JSONgen JSON generator · _TCPServer UDF multi-client and multi-task (run on background) event-based TCP server easy to do · _TCPClient_UDF multi-server and multi-task (runs on background) event-based TCP client easy to do · ParseURL and ParseStr functions ported from PHP · _CmdLine UDF easily parse command line parameters, keys or flags · AutoPHP Create documents (bills, incomes) from HTML by sending variables/arrays from AutoIt to PHP · (Un)Serialize Convert arrays and data into a storable string (PHP compatible) · RTTL Plays and exports to MP3 Nokia-format monophonic ringtones (for very old cellphones) · I18n library Simple and easy to use localization library · Scripting.Dictionary OOP and OOP-like approach · Buffer/stack limit arrays to N items by removing the last one once the limit is reached · NGBioAPI UDF to work with Nitgen fingerprint readers · Serial/Licensing system require license key based on unique machine ID from your users · HTTP a simple WinHTTP library that allows GET, POST and file uploads · Thread true AutoIt threads (under-dev) · RC4 RC4 encryption compatible with PHP and JS · storage.au3 localStorage and sessionStorage for AutoIt Classes _WKHtmlToX uses wkhtmlto* to convert HTML files and webpages into PDF or images (jpg, bmp, gif, png...) Snippets _Word_DocFindReplaceByLongText replace strings using Word UDF with strings longer than 255 characters (MSWord limit) rangeparser parser for printing-like pages interval (e.g.: "1,2,3-5") EnvParser parse strings/paths with environment variables and get full path GUICtrlStaticMarquee static text scrolling Random stuff Super Mario beep sound your ears will hurt Link to comment Share on other sites More sharing options...
faustf Posted October 3, 2019 Author Share Posted October 3, 2019 retrun 403 response Link to comment Share on other sites More sharing options...
Developers Jos Posted October 3, 2019 Developers Share Posted October 3, 2019 (edited) So, what do you think a 403 response means with websites? Jos Edited October 3, 2019 by Jos SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
jchd Posted October 3, 2019 Share Posted October 3, 2019 (edited) 403: a good starting point for an investigation! Spoiler Hint: his car is a Peugeot 403 Edited October 3, 2019 by jchd Earthshine and FrancescoDiMuro 2 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...
Musashi Posted October 3, 2019 Share Posted October 3, 2019 1 hour ago, faustf said: return 403 response To answer this question, you don't have to annoy Detective Columbo . It is sufficient to simply enter Http error 403 at Google. https://en.wikipedia.org/wiki/HTTP_403 https://www.howtogeek.com/357785/what-is-a-403-forbidden-error-and-how-can-i-fix-it/ @faustf : I am slightly surprised that a member with 1000+ posts asks such a question (not meant to be insulting). Earthshine 1 "In the beginning the Universe was created. This has made a lot of people very angry and been widely regarded as a bad move." Link to comment Share on other sites More sharing options...
Developers Jos Posted October 3, 2019 Developers Share Posted October 3, 2019 1 hour ago, Musashi said: @faustf : I am slightly surprised that a member with 1000+ posts asks such a question (not meant to be insulting). Stop being surprised and yes this is meant as it sounds as this has been told to the OP a zillion times. Jos Earthshine 1 SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
Danyfirex Posted October 4, 2019 Share Posted October 4, 2019 Hello. Main Issue I see in your code is you send data in the get query, the correct way is that the parameters and signature need to be part of the URI. Saludos Danysys.com AutoIt... UDFs: VirusTotal API 2.0 UDF - libZPlay UDF - Apps: Guitar Tab Tester - VirusTotal Hash Checker Examples: Text-to-Speech ISpVoice Interface - Get installed applications - Enable/Disable Network connection PrintHookProc - WINTRUST - Mute Microphone Level - Get Connected NetWorks - Create NetWork Connection ShortCut Link to comment Share on other sites More sharing options...
faustf Posted October 9, 2019 Author Share Posted October 9, 2019 how to do that you have ome example?? thankz Link to comment Share on other sites More sharing options...
TheXman Posted October 9, 2019 Share Posted October 9, 2019 (edited) On 9/18/2019 at 8:07 AM, faustf said: i try to create something like this but not understund if work good because i am not good for use http request Really?!? Then where is the code that you created? Because the code that you posted looks exactly like the code in the post below (which of course doesn't work). As Danyfirex said, if the API call is a GET, then the URI should include the params, not sent as request data (which would be a POST). Edited October 9, 2019 by TheXman CryptoNG UDF: Cryptography API: Next Gen jq UDF: Powerful and Flexible JSON Processor | jqPlayground: An Interactive JSON Processor Xml2Json UDF: Transform XML to JSON | HttpApi UDF: HTTP Server API | Roku Remote: Example Script About Me How To Ask Good Questions On Technical And Scientific Forums (Detailed) | How to Ask Good Technical Questions (Brief) "Any fool can know. The point is to understand." -Albert Einstein "If you think you're a big fish, it's probably because you only swim in small ponds." ~TheXman Link to comment Share on other sites More sharing options...
faustf Posted October 9, 2019 Author Share Posted October 9, 2019 (edited) thankz at all for help i just start to understund somthing about http func _de() ; https://github.com/binance-exchange/binance-official-api-docs/blob/master/rest-api.md site with information on Binance API calls $oHTTP = ObjCreate("winhttp.winhttprequest.5.1") $oHTTP.Open("GET", "https://api.binance.com/api/v1/exchangeInfo", False) $oHTTP.SetRequestHeader("User-Agent", 'Mozilla/5.0 (Windows NT 10.0; WOW64) WinHttp/1.6.3.9 (WinHTTP/5.1) like Gecko') $oHTTP.Send() $oReceived = $oHTTP.ResponseText $oStatusCode = $oHTTP.Status If $oStatusCode <> 200 Then MsgBox(4096, "Response code", $oStatusCode) EndIf ;ConsoleWrite("Response Text >> " & $oReceived & @CRLF & @CRLF) EndFunc dont worry @TheXman I don't want to take merit for the scripts of others, i create a script is only way of saying........ I thought you understood but, Welcome.. I appreciate your clarification :D, and your suggest Edited October 9, 2019 by faustf 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