Jump to content

Search the Community

Showing results for tags 'restful'.



More search options

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • General
    • Announcements and Site News
    • Administration
  • AutoIt v3
    • AutoIt Help and Support
    • AutoIt Technical Discussion
    • AutoIt Example Scripts
  • Scripting and Development
    • Developer General Discussion
    • Language Specific Discussion
  • IT Administration
    • Operating System Deployment
    • Windows Client
    • Windows Server
    • Office

Categories

  • AutoIt Team
    • Beta
    • MVP
  • AutoIt
    • Automation
    • Databases and web connections
    • Data compression
    • Encryption and hash
    • Games
    • GUI Additions
    • Hardware
    • Information gathering
    • Internet protocol suite
    • Maths
    • Media
    • PDF
    • Security
    • Social Media and other Website API
    • Windows
  • Scripting and Development
  • IT Administration
    • Operating System Deployment
    • Windows Client
    • Windows Server
    • Office

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


Location


WWW


Interests

Found 2 results

  1. About AutoIt-API-WS AutoIt-API-WS is a light weight web server with expressive syntax, with the sole purpose of wrapping your existing AutoIt app with little to no effort. With AutoIt-API-WS you can send and receive data between any application or framework, as long they can handle HTTP requests, which is an industry standard today. Like my other communcations UDF AutoIt-Socket-IO AutoIt-API-WS is heavily inspired from the big boys, but this time its Laravel and Ruby on Rails. Features Highlights No external or internal dependencies required RESTful mindset when designed Expressive syntax Small codebase Heavy use of Michelsofts Dictionary object Limitations Not complient with any RFC, so something important could be missing. Time will tell! One persons slow loris attack will kill the process forever. Example of implemetnation (With screenshots) This is a basic cRud operation with the RESTful mindset in use. #include "API.au3" #include <Array.au3> _API_MGR_SetName("My APP DB adapter") _API_MGR_SetVer("1.0 BETA") _API_MGR_SetDescription("This adapter allows you to get this n that") _API_MGR_Init(3000) _API_MGR_ROUTER_GET('/users', CB_GetUsers, 'string sortBy', 'Get all users, sortBy can be either asc or desc. asc is default') _API_MGR_ROUTER_GET('/users/{id}', CB_GetUsersById, 'int id*', 'Get user by id') While _API_MGR_ROUTER_HANDLE() WEnd Func DB_GetUsers() Local $userA = ObjCreate("Scripting.Dictionary") Local $userB = ObjCreate("Scripting.Dictionary") $userA.add('id', 1) $userA.add('name', 'TarreTarreTarre') $userA.add('age', 27) $userB.add('id', 2) $userB.add('name', @UserName) $userB.add('age', 22) Local $aRet = [$userA, $userB] Return $aRet EndFunc Func CB_GetUsers(Const $oRequest) Local $aUsers = DB_GetUsers() If $oRequest.exists('sortBy') Then Switch $oRequest.item('sortBy') Case Default Case 'asc' Case 'desc' _ArrayReverse($aUsers) EndSwitch EndIf Return $aUsers EndFunc Func CB_GetUsersById(Const $oRequest) Local Const $aUsers = DB_GetUsers() Local $foundUser = Null For $i = 0 To UBound($aUsers) -1 Local $curUser = $aUsers[$i] If $curUser.item('id') == $oRequest.item('#id') Then $foundUser = $curUser ExitLoop EndIf Next If Not IsObj($foundUser) Then Return _API_RES_NotFound(StringFormat("Could not find user with ID %d", $oRequest.item('#id'))) EndIf return $foundUser EndFunc When you visit http://localhost:3000 you are greeted with this pleasent view that will show you all your registred routes and some extra info you have provided. When you visit http://localhost:3000/users the UDF will return the array of objects as Json And here is an example of http://localhost:3000/users/1 More examples can be found here Autoit-API-WS-1.0.0-beta.zip (OLD!) Autoit-API-WS-1.0.1-beta.zip (NEWEST 2020-06-29)
  2. Today I want to present my current project. This is UDF for crowdin.net website API In fact, not yet finished but functional. #AutoIt3Wrapper_Au3Check_Parameters=-d -w 1 -w 2 -w 3 -w- 4 -w 5 -w 6 -w 7 #Tidy_Parameters=/sort_funcs /reel #include <FileConstants.au3> #include <MsgBoxConstants.au3> _Crowdin_Example_1() Func _Crowdin_Example_1() Local $sACCOUNT_API_KEY = '...' Local $sPROJECT_API_KEY = '...' Local $sPROJECT_identifier = '...' Local $output = '' _Crowdin_Project_Identifier($sPROJECT_identifier) _Crowdin_Project_ApiKey($sPROJECT_API_KEY) _Crowdin_AccountKey($sACCOUNT_API_KEY) $output = _Crowdin_DirectoryCreate('Directory for testing CrowdinAPI') MsgBox(0, '_Crowdin_DirectoryCreate', $output) Exit $output = _Crowdin_GetProjectInfo() MsgBox(0, '_Crowdin_GetProjectInfo', $output) $output = _Crowdin_GetSupportedLanguages() MsgBox(0, '_Crowdin_GetSupportedLanguages', $output) $output = _Crowdin_TranslationExport() MsgBox(0, '_Crowdin_TranslationExport', $output) $output = _Crowdin_TranslationStatus() MsgBox(0, '_Crowdin_TranslationStatus', $output) $output = _Crowdin_TranslationDownload('all', @ScriptDir & '\Crowdin_test_DownloadTranslations.zip') $output = _Crowdin_GetProjects('mLipok') MsgBox(0, '_Crowdin_GetProjects', $output) $output = _Crowdin_DirectoryCreate('Directory for testing CrowdinAPI') MsgBox(0, '_Crowdin_DirectoryCreate', $output) ;~ $output = ;~ MsgBox(0, '', $output) EndFunc ;==>_Crowdin_Example_1 #Region CrowdinAPI - Functions ; #FUNCTION# ==================================================================================================================== ; Name ..........: _Crowdin_GetProjectInfo ; Description ...: Get Crowdin Project details. ; Syntax ........: _Crowdin_GetProjectInfo() ; Parameters ....: ; Return values .: None ; Author ........: mLipok ; Modified ......: ; Remarks .......: ; Related .......: ; Link ..........: ; Example .......: No ; =============================================================================================================================== Func _Crowdin_GetProjectInfo() Local $sURL = 'https://api.crowdin.com/api/project/' & _Crowdin_Project_Identifier() & '/info?key=' & _Crowdin_Project_ApiKey() ConsoleWrite('! ' & $sURL & @CRLF) Local $oXmlHttp = ObjCreate("Microsoft.XMLHTTP") $oXmlHttp.Open('POST', $sURL, False) $oXmlHttp.Send() Local $output = $oXmlHttp.ResponseText $oXmlHttp = '' Return $output EndFunc ;==>_Crowdin_GetProjectInfo ; #FUNCTION# ==================================================================================================================== ; Name ..........: _Crowdin_GetSupportedLanguages ; Description ...: ; Syntax ........: _Crowdin_GetSupportedLanguages() ; Parameters ....: ; Return values .: None ; Author ........: mLipok ; Modified ......: ; Remarks .......: ; Related .......: ; Link ..........: ; Example .......: No ; =============================================================================================================================== Func _Crowdin_GetSupportedLanguages() Local $sURL = 'https://api.crowdin.com/api/supported-languages' ConsoleWrite('! ' & $sURL & @CRLF) Local $oXmlHttp = ObjCreate("Microsoft.XMLHTTP") $oXmlHttp.Open('GET', $sURL, False) $oXmlHttp.Send() Local $output = $oXmlHttp.ResponseText $oXmlHttp = '' Return $output EndFunc ;==>_Crowdin_GetSupportedLanguages ; #FUNCTION# ==================================================================================================================== ; Name ..........: _Crowdin_TranslationExport ; Description ...: ; Syntax ........: _Crowdin_TranslationExport() ; Parameters ....: ; Return values .: None ; Author ........: mLipok ; Modified ......: ; Remarks .......: ; Related .......: ; Link ..........: ; Example .......: No ; =============================================================================================================================== Func _Crowdin_TranslationExport() Local $sURL = 'https://api.crowdin.com/api/project/' & _Crowdin_Project_Identifier() & '/export?key=' & _Crowdin_Project_ApiKey() ConsoleWrite('! ' & $sURL & @CRLF) Local $oXmlHttp = ObjCreate("Microsoft.XMLHTTP") $oXmlHttp.Open('GET', $sURL, False) $oXmlHttp.Send() Local $output = $oXmlHttp.ResponseText $oXmlHttp = '' Return $output EndFunc ;==>_Crowdin_TranslationExport ; #FUNCTION# ==================================================================================================================== ; Name ..........: _Crowdin_TranslationStatus ; Description ...: Track your Crowdin project translation progress by language. Default response format is XML. ; Syntax ........: _Crowdin_TranslationStatus() ; Parameters ....: ; Return values .: None ; Author ........: mLipok ; Modified ......: ; Remarks .......: ; Related .......: ; Link ..........: https://crowdin.com/page/api/status ; Example .......: No ; =============================================================================================================================== Func _Crowdin_TranslationStatus() Local $sURL = 'https://api.crowdin.com/api/project/' & _Crowdin_Project_Identifier() & '/status?key=' & _Crowdin_Project_ApiKey() ConsoleWrite('! ' & $sURL & @CRLF) Local $oXmlHttp = ObjCreate("Microsoft.XMLHTTP") $oXmlHttp.Open('POST', $sURL, False) $oXmlHttp.Send() Local $output = $oXmlHttp.ResponseText $oXmlHttp = '' Return $output EndFunc ;==>_Crowdin_TranslationExport ; #FUNCTION# ==================================================================================================================== ; Name ..........: _Crowdin_TranslationDownload ; Description ...: Download ZIP file with translations. You can choose the language of translation you need or download all of them at once. ; Syntax ........: _Crowdin_TranslationDownload([$sPackage = 'all'[, $sZIP_FileFullPath = '']]) ; Parameters ....: $sPackage - [optional] a string value. Default is 'all'. ; $sZIP_FileFullPath - [optional] a string value. Default is ''. ; Return values .: None ; Author ........: mLipok ; Modified ......: ; Remarks .......: ; Related .......: ; Link ..........: https://crowdin.com/page/api/download ; Example .......: No ; =============================================================================================================================== Func _Crowdin_TranslationDownload($sPackage = 'all', $sZIP_FileFullPath = '') ; GET https://api.crowdin.com/api/project/{project-identifier}/download/{package}.zip?key={project-key} Local $sURL = 'https://api.crowdin.com/api/project/' & _Crowdin_Project_Identifier() & '/download/' & $sPackage & '.zip?key=' & _Crowdin_Project_ApiKey() ConsoleWrite('! ' & $sURL & @CRLF) Local $oXmlHttp = ObjCreate("Microsoft.XMLHTTP") $oXmlHttp.Open('GET', $sURL, False) $oXmlHttp.Send() Local $output = $oXmlHttp.ResponseBody ;~ Local $type = $oXmlHttp.ResponseType ;~ MsgBox(0, VarGetType($type) & '='&$type&'=' , VarGetType($output)) ;~ MsgBox(0, '', BinaryLen($output)) If $sZIP_FileFullPath <> '' Then Local $hFile = FileOpen($sZIP_FileFullPath, $FO_OVERWRITE + $FO_BINARY) FileWrite($hFile, $output) FileClose($hFile) EndIf $oXmlHttp = '' Return $output EndFunc ;==>_Crowdin_TranslationDownload ; #FUNCTION# ==================================================================================================================== ; Name ..........: _Crowdin_GetProjects ; Description ...: Get Crowdin Project details. ; Syntax ........: _Crowdin_GetProjects($sLoginName) ; Parameters ....: $sLoginName - A string value. Your Crowdin Account login name. ; Return values .: None ; Author ........: mLipok ; Modified ......: ; Remarks .......: ; Related .......: ; Link ..........: https://crowdin.com/page/api/get-projects ; Example .......: No ; =============================================================================================================================== Func _Crowdin_GetProjects($sLoginName) ; https://api.crowdin.com/api/account/get-projects?account-key={account-key} Local $sURL = 'https://api.crowdin.com/api/account/get-projects?account-key=' & _Crowdin_AccountKey() & '&login=' & $sLoginName ConsoleWrite('! ' & $sURL & @CRLF) Local $oXmlHttp = ObjCreate("Microsoft.XMLHTTP") $oXmlHttp.Open('POST', $sURL, False) $oXmlHttp.Send('') Local $output = $oXmlHttp.ResponseText $oXmlHttp = '' Return $output EndFunc ;==>_Crowdin_GetProjects ; #FUNCTION# ==================================================================================================================== ; Name ..........: _Crowdin_DirectoryCreate ; Description ...: Add directory to Crowdin project. ; Syntax ........: _Crowdin_DirectoryCreate($sDirectoryName) ; Parameters ....: $sDirectoryName - A string value. ; Return values .: None ; Author ........: Your mLipok ; Modified ......: ; Remarks .......: ; Related .......: ; Link ..........: https://crowdin.com/page/api/add-directory ; Example .......: No ; =============================================================================================================================== Func _Crowdin_DirectoryCreate($sDirectoryName) ; https://api.crowdin.com/api/project/{project-identifier}/add-directory?key={project-key} Local $sURL = 'https://api.crowdin.com/api/project/' & _Crowdin_Project_Identifier() & '/add-directory?key=' & _Crowdin_Project_ApiKey() & '&name=' & $sDirectoryName ConsoleWrite('! ' & $sURL & @CRLF) Local $oXmlHttp = ObjCreate("Microsoft.XMLHTTP") $oXmlHttp.Open('POST', $sURL, False) $oXmlHttp.Send('') Local $output = $oXmlHttp.ResponseText $oXmlHttp = '' Return $output EndFunc ;==>_Crowdin_GetProjects #EndRegion CrowdinAPI - Functions #Region CrowdinAPI - SETUP ; #FUNCTION# ==================================================================================================================== ; Name ..........: _Crowdin_Project_ApiKey ; Description ...: ; Syntax ........: _Crowdin_Project_ApiKey([$vApiKey = Default]) ; Parameters ....: $vApiKey - [optional] a variant value. Default is Default. ; Return values .: None ; Author ........: mLipok ; Modified ......: ; Remarks .......: ; Related .......: ; Link ..........: https://crowdin.com/page/api/authentication ; Example .......: No ; =============================================================================================================================== Func _Crowdin_Project_ApiKey($vApiKey = Default) Local Static $sPROJECT_API_KEY = '' If $vApiKey = Default Then Return $sPROJECT_API_KEY Else $sPROJECT_API_KEY = $vApiKey Return $sPROJECT_API_KEY EndIf EndFunc ;==>_Crowdin_Project_ApiKey ; #FUNCTION# ==================================================================================================================== ; Name ..........: _Crowdin_Project_Identifier ; Description ...: ; Syntax ........: _Crowdin_Project_Identifier([$vIdentifier = Default]) ; Parameters ....: $vIdentifier - [optional] a variant value. Default is Default. ; Return values .: None ; Author ........: mLipok ; Modified ......: ; Remarks .......: ; Related .......: ; Link ..........: https://crowdin.com/page/api/authentication ; Example .......: No ; =============================================================================================================================== Func _Crowdin_Project_Identifier($vIdentifier = Default) Local Static $sPROJECT_identifier = '' If $vIdentifier = Default Then Return $sPROJECT_identifier Else $sPROJECT_identifier = $vIdentifier Return $sPROJECT_identifier EndIf EndFunc ;==>_Crowdin_Project_Identifier ; #FUNCTION# ==================================================================================================================== ; Name ..........: _Crowdin_AccountKey ; Description ...: ; Syntax ........: _Crowdin_AccountKey([$vAccountKey = Default]) ; Parameters ....: $vAccountKey - [optional] A variant value. Default is Default. ; Return values .: None ; Author ........: mLipok ; Modified ......: ; Remarks .......: ; Related .......: ; Link ..........: https://crowdin.com/settings#user-profile-api-key ; Example .......: No ; =============================================================================================================================== Func _Crowdin_AccountKey($vAccountKey = Default) Local Static $sACCOUNT_API_KEY = '' If $vAccountKey = Default Then Return $sACCOUNT_API_KEY Else $sACCOUNT_API_KEY = $vAccountKey Return $sACCOUNT_API_KEY EndIf EndFunc ;==>_Crowdin_AccountKey #EndRegion CrowdinAPI - SETUP CrowdinAPI_v0.1.au3 have fun, mLipok
×
×
  • Create New...