Search the Community
Showing results for tags 'prowl udf'.
-
Hi All, In a recent project of mine I needed to send multiple message to an app on my Iphone called Prowl. Hopefully this will come in useful to someone. #Include-Once #include <WinHttp.au3> ; #INDEX# ========================================================================================= ; Title .........: Prowl UDF ; AutoIt Version : 3.3.8++ ; Language ..... : English ; Description ...: Functions for use with Prowl App (http://www.prowlapp.com/) API ; Author(s) .....: mrflibblehat (danielcarroll@gmail.com) ; ================================================================================================= ; #GLOBALS# ======================================================================================= Global Const $vProwl = "api.prowlapp.com" ;~ Prowl API Site Global $vOpen = 0, $vConnect = 0 ; ================================================================================================= ; #CURRENT# ======================================================================================= ;_Prowl_Open ;_Prowl_Close ;_ProwlAdd ; ================================================================================================= ; #FUNCTION# ==================================================================================================================== ; Name...........: _Prowl_Open ; Description ...: Create Session and Connection Handle ; Syntax.........: _Prowl_Open ; Return values .: Failure - Returns 0 and Sets @Error: ; |@error = 1 - Error Opening WinHTTP Handle ; |@error = 2 - Error Opening WinHTTPConnect Handle ; Author ........: mrflibblehat (danielcarroll@gmail.com) ; =============================================================================================================================== Func _Prowl_Open() $vOpen = _WinHttpOpen() if (@error) then Return SetError(1, 0, "Error Opening WinHTTP Handle") $vConnect = _WinHttpConnect($vOpen, $vProwl) if (@error) then Return SetError(2, 0, "Error Opening WinHTTPConnect Handle") EndFunc ; #FUNCTION# ==================================================================================================================== ; Name...........: _Prowl_Close ; Description ...: Close Session and Connection Handle ; Syntax.........: _Prowl_Close ; Author ........: mrflibblehat (danielcarroll@gmail.com) ; =============================================================================================================================== Func _Prowl_Close() _WinHttpCloseHandle($vConnect) _WinHttpCloseHandle($vOpen) EndFunc ; #FUNCTION# ==================================================================================================================== ; Name ..........: _ProwlAdd ; Description ...: ; Syntax ........: _ProwlAdd($vAPIKey, $vEvent, $vDescription[, $vPriority = 0[, $vApplicationName = "Prowl 4 AutoIT"[, $vProviderKey = ""[, $vURL = ""]]]]) ; Parameters ....: $vAPIKey - Prowl API Key ; $vEvent - Name of Event. ; $vDescription - Message to Send. ; $vPriority - [optional] Priority of Message. Default is 0 - Normal. -2 - Very Low | -1 - Moderate | 0 - Normal | 1 - High | 2 - Emergency ; $vApplicationName - [optional] Application Name. Default is "Prowl 4 AutoIT" ; $vProviderKey - [optional] Your provider API key. Only necessary if you have been whitelisted. Default is "". ; $vURL - [optional] Requires Prowl 1.2 The URL which should be attached to the notification. Default is "". ; Return values .: XML response from server ; Author ........: mrflibblehat (danielcarroll@gmail.com) ; =============================================================================================================================== Func _ProwlAdd($vAPIKey, $vEvent, $vDescription, $vPriority = 0, $vApplicationName = "Prowl 4 AutoIT", $vProviderKey = "", $vURL = "") Local $sData = ("apikey=" & $vAPIKey & "&application=" & $vApplicationName & "&event=" & $vEvent & "&description=" & $vDescription & "&priority=" & $vPriority & "&providerkey=" & $vProviderKey & "&url=" & $vURL) Local $vRequest = _WinHttpSimpleRequest($vConnect, "POST", "/publicapi/add/", $WINHTTP_NO_REFERER, $sData, "Content-Type: application/x-www-form-urlencoded") if (@error) then Return SetError(3, 0, "Unable To Send Request") Return $vRequest EndFunc Example #include <ProwlUDF.au3> Global $vApiKey = "PUT API KEY HERE" _Prowl_Open() _ProwlAdd($vApiKey, "Test", "Test Message") _Prowl_Close()