Jump to content

Recommended Posts

Posted (edited)

Hi All,

Please see code attached for my first UDF Attempt,

I needed some functions for pastebin so decided to clean them up a bit and share with you guys. You need to add your Pastebin Developer Key to the top of the UDF for functionality.

Hope someone finds these useful.

You will need the WinHttp.au3 UDF to make this work. https://code.google.com/p/autoit-winhttp/downloads/list

#Include-Once

#include <WinHttp.au3>

; #INDEX# =========================================================================================
; Title .........: Pastebin UDF
; AutoIt Version : 3.3.8++
; Language ..... : English
; Description ...: Functions for use with Pastebin.com API
; Author(s) .....: mrflibblehat (danielcarroll@gmail.com)
; =================================================================================================

; #GLOBALS# =====================================================================================
Global Const $vPasteBin = "pastebin.com" ;~ PasteBin Website
Global Const $vAPIDevKey = "" ;~ Obtain The Developer Key From Pastebin
Global $vOpen = 0, $vConnect = 0
; ===============================================================================================

; #CURRENT# =======================================================================================
;_PB_Open
;_PB_Close
;_CreatePaste
;_DeletePaste
;_CreateAPIUserKey
;_ListUserPastes
;_ListTrendingPastes
;_UserDetails
;_GetRawPaste
; =================================================================================================

; #FUNCTION# ====================================================================================================================
; Name...........: _PB_Open
; Description ...: Create Session and Connection Handle
; Syntax.........: _PB_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 _PB_Open()
   $vOpen = _WinHttpOpen()
      if (@error) then Return SetError(1, 0, "Error Opening WinHTTP Handle")
   $vConnect = _WinHttpConnect($vOpen, $vPasteBin)
      if (@error) then Return SetError(2, 0, "Error Opening WinHTTPConnect Handle")
EndFunc
   
; #FUNCTION# ====================================================================================================================
; Name...........: _PB_Close
; Description ...: Close Session and Connection Handle
; Syntax.........: _PB_Close
; Author ........: mrflibblehat (danielcarroll@gmail.com)
; ===============================================================================================================================
Func _PB_Close()
   _WinHttpCloseHandle($vConnect)
   _WinHttpCloseHandle($vOpen)
EndFunc

; #FUNCTION# ====================================================================================================================
; Name...........: _CreatePaste
; Description ...: Creates a new paste and returns pastebin link
; Syntax.........: _CreatePaste($vPasteCode, $vPasteName[, $vPasteFormat = "text"[, $vPublicity = 1[, $vPasteExpireDate = "N" [, $vAPIUserKey = ""]]]] )
; Parameters ....: $vPasteCode - Put Paste Code Here
;                  $vPasteName - Name of Your Paste
;                  $vPasteFormat - Set Syntax Highlighting Format (autoit, php, c, c++, vb, html etc)
;                  $vPublicity - Set The Publicity of Your Paste (0 = Public, 1 = Private, 2 = Unlisted)
;                  $vPasteExpireDate - Set The Paste Expiry Date (N = Never, 10M = 10 Minutes, 1D = 1 Day, 1W = 1 Week etc)
;                  $vAPIUserKey - To Paste as a User, Only if You Have Created an API User Key (See _CreateAPIUserKey)
; Return values .: Success      - Returns Pastebin Paste Link
; Author ........: mrflibblehat (danielcarroll@gmail.com)
; ===============================================================================================================================
Func _CreatePaste($vPasteCode, $vPasteName, $vPasteFormat = "text", $vPublicity = 1, $vPasteExpireDate = "N", $vAPIUserKey = "")
   Local $sData = ("api_option=paste&api_user_key=" & $vAPIUserKey & "&api_paste_private=" & $vPublicity & "&api_paste_name=" & $vPasteName & "&api_paste_expire_date= " & $vPasteExpireDate & "&api_paste_format=" & $vPasteFormat & "&api_dev_key=" & $vAPIDevKey & "&api_paste_code=" & $vPasteCode)
   Local $vRequest = _WinHttpSimpleRequest($vConnect, "POST", "/api/api_post.php", $WINHTTP_NO_REFERER, $sData, "Content-Type: application/x-www-form-urlencoded")
      if (@error) then Return SetError(3, 0, "Unable To Send Request")
   Return SetError(0, 0, $vRequest)
EndFunc

; #FUNCTION# ====================================================================================================================
; Name...........: _CreateAPIUserKey
; Description ...: Creates an API User Key
; Syntax.........: _CreateAPIUserKey($vUsername, $vPassword)
; Parameters ....: $vUsername - Pastebin Username
;                  $vPassword - Pastebin Password
; Return values .: Success      - Returns Pastebin API User Key
; Author ........: mrflibblehat (danielcarroll@gmail.com)
; ===============================================================================================================================
Func _CreateAPIUserKey($vUsername, $vPassword)
   Local $sData = ("api_dev_key=" & $vAPIDevKey & "&api_user_name=" & $vUsername & "&api_user_password=" & $vPassword)
   Local $vRequest = _WinHttpSimpleRequest($vConnect, "POST", "/api/api_post.php", $WINHTTP_NO_REFERER, $sData, "Content-Type: application/x-www-form-urlencoded")
      if (@error) then Return SetError(3, 0, "Unable To Send Request")
   Return SetError(0, 0, $vRequest)
EndFunc

; #FUNCTION# ====================================================================================================================
; Name...........: _ListUserPastes
; Description ...: List Pastes by Given API User Key
; Syntax.........: _CreateAPIUserKey($vAPIUserKey[, $vAPIResultsLimit = 50])
; Parameters ....: $vAPIUserKey - Pastebin API User Key
;                  $vAPIResultsLimit - Limit Results Displayed
; Return values .: Success      - Returns List of Pastebin Pastes
; Author ........: mrflibblehat (danielcarroll@gmail.com)
; ===============================================================================================================================
Func _ListUserPastes($vAPIUserKey, $vAPIResultsLimit = 50)
   Local $sData = ("api_option=list&api_user_key=" & $vAPIUserKey &"&api_dev_key=" & $vAPIDevKey & "&api_results_limit=" & $vAPIResultsLimit)
   Local $vRequest = _WinHttpSimpleRequest($vConnect, "POST", "/api/api_post.php", $WINHTTP_NO_REFERER, $sData, "Content-Type: application/x-www-form-urlencoded")
      if (@error) then Return SetError(3, 0, "Unable To Send Request")
   Return SetError(0, 0, $vRequest)
EndFunc

; #FUNCTION# ====================================================================================================================
; Name...........: _ListTrendingPastes
; Description ...: Creates an API User Key
; Syntax.........: _ListTrendingPastes()
; Parameters ....: 
; Return values .: Success      - Returns a 0 based array showing top trends
; Author ........: mrflibblehat (danielcarroll@gmail.com)
; ===============================================================================================================================
Func _ListTrendingPastes()
   Local $vDataArr[18][10]
   Local $sData = ("api_option=trends&api_dev_key=" & $vAPIDevKey)
   Local $vRequest = _WinHttpSimpleRequest($vConnect, "POST", "/api/api_post.php", $WINHTTP_NO_REFERER, $sData, "Content-Type: application/x-www-form-urlencoded")
      if (@error) then Return SetError(3, 0, "Unable To Send Request")
   
   $vPasteKey = StringRegExp($vRequest, "<paste_key>(.*?)</paste_key>", 3)
   $vPasteDate = StringRegExp($vRequest, "<paste_date>(.*?)</paste_date>", 3)
   $vPasteTitle = StringRegExp($vRequest, "<paste_title>(.*?)</paste_title>", 3)
   $vPasteSize = StringRegExp($vRequest, "<paste_size>(.*?)</paste_size>", 3)
   $vPasteExpiry = StringRegExp($vRequest, "<paste_expire_date>(.*?)</paste_expire_date>", 3)
   $vPastePrivate = StringRegExp($vRequest, "<paste_private>(.*?)</paste_private>", 3)
   $vPasteFormatL = StringRegExp($vRequest, "<paste_format_long>(.*?)</paste_format_long>", 3)
   $vPasteFormatS = StringRegExp($vRequest, "<paste_format_short>(.*?)</paste_format_short>", 3)
   $vPasteURL = StringRegExp($vRequest, "<paste_url>(.*?)</paste_url>", 3)
   $vPasteHits = StringRegExp($vRequest, "<paste_hits>(.*?)</paste_hits>", 3)
   
   For $i = 0 to 17
      
      $vDataArr[$i][0] = $vPasteKey[$i] ;~ Paste Key
      $vDataArr[$i][1] = $vPasteDate[$i]  ;~ Paste Date
      $vDataArr[$i][2] = $vPasteTitle[$i] ;~ Paste Title
      $vDataArr[$i][3] = $vPasteSize[$i] ;~ Paste Size (KB)
      $vDataArr[$i][4] = $vPasteExpiry[$i] ;~ Paste Expiry Time
      $vDataArr[$i][5] = $vPastePrivate[$i] ;~ Paste Publicity
      $vDataArr[$i][6] = $vPasteFormatL[$i] ;~ Paste Format Long
      $vDataArr[$i][7] = $vPasteFormatS[$i] ;~ Paste Formate Short
      $vDataArr[$i][8] = $vPasteURL[$i] ;~ Paste URL
      $vDataArr[$i][9] = $vPasteHits[$i] ;~ Paste Hits
      
   Next
   
   Return SetError(0, 0, $vDataArr)
EndFunc

; #FUNCTION# ====================================================================================================================
; Name...........: _DeletePaste
; Description ...: Delete a Given Users Paste
; Syntax.........: _DeletePaste($vAPIUserKey, $vPasteKey)
; Parameters ....: $vAPIUserKey - Pastebin API User Key
;                  $vPasteKey - Paste Key, Obtained From _ListUserPastes Function
; Return values .: Success      - Deletes Paste Returns "Paste Removed"
; Author ........: mrflibblehat (danielcarroll@gmail.com)
; ===============================================================================================================================
Func _DeletePaste($vAPIUserKey, $vPasteKey)
   Local $sData = ("api_option=delete&api_user_key=" & $vAPIUserKey & "&api_dev_key=" & $vAPIDevKey & "&api_paste_key=" & $vPasteKey)
   Local $vRequest = _WinHttpSimpleRequest($vConnect, "POST", "/api/api_post.php", $WINHTTP_NO_REFERER, $sData, "Content-Type: application/x-www-form-urlencoded")
      if (@error) then Return SetError(3, 0, "Unable To Send Request")
   Return SetError(0, 0, $vRequest)
EndFunc

; #FUNCTION# ====================================================================================================================
; Name...........: _UserDetails
; Description ...: Delete a Given Users Paste
; Syntax.........: _UserDetails($vAPIUserKey)
; Parameters ....: $vAPIUserKey - Pastebin API User Key
; Return values .: Success      - Returns User Details
; Author ........: mrflibblehat (danielcarroll@gmail.com)
; ===============================================================================================================================
Func _UserDetails($vAPIUserKey)
   Local $sData = ("api_option=userdetails&api_user_key=" & $vAPIUserKey & "&api_dev_key=" & $vAPIDevKey)
   Local $vRequest = _WinHttpSimpleRequest($vConnect, "POST", "/api/api_post.php", $WINHTTP_NO_REFERER, $sData, "Content-Type: application/x-www-form-urlencoded")
      if (@error) then Return SetError(3, 0, "Unable To Send Request")
   Return SetError(0, 0, $vRequest)
EndFunc

; #FUNCTION# ====================================================================================================================
; Name...........: _GetRawPaste
; Description ...: Delete a Given Users Paste
; Syntax.........: _GetRawPaste($vPasteUrl)
; Parameters ....: $vPasteUrl - Pastebin URL
; Return values .: Success      - Returns Paste
; Author ........: mrflibblehat (danielcarroll@gmail.com)
; ===============================================================================================================================
Func _GetRawPaste($vPasteUrl)
   $vPasteKey = StringRegExp($vPasteUrl, "pastebin.com/(\H+)", 3)
      if (@error) then Return SetError(3, 0, "Unable To Read URL")
Local $vRequest = _WinHttpSimpleRequest($vConnect, "GET", "/raw.php?i=" & $vPasteKey[0])
      if (@error) then Return SetError(3, 0, "Unable To Connect To URL")
   Return SetError(0, 0, $vRequest)
EndFunc   

Example

#Include <Pastebin.au3>
#include <Array.au3>


_PB_Open()

   ;~ Create A New Paste And Return URL To Console
   $vPaste = _CreatePaste("This is a test paste", "Title of Test Paste")
     ConsoleWrite("Created Paste: " & $vPaste & @CRLF)

   ;~ Get Trending Pastes And Show in _ArrayDisplay
   $vTrends = _ListTrendingPastes()
      _ArrayDisplay($vTrends)
      
   ;~ Print Paste To Console
   $RawPaste = _GetRawPaste("http://pastebin.com/8sTHzAD7")
      ConsoleWrite("Raw Paste: " & $RawPaste)
      
_PB_Close()
Edited by mrflibblehat

[font="'courier new', courier, monospace;"]Pastebin UDF | Prowl UDF[/font]

Posted

Looks fine to me and I have a PasteBin application, so I have some understanding. (See my signature.)

You could use InetRead and http://pastebin.com/raw.php?i= (see the API docs) to retrieve the paste id.

UDF List:

 
_AdapterConnections()_AlwaysRun()_AppMon()_AppMonEx()_ArrayFilter/_ArrayReduce_BinaryBin()_CheckMsgBox()_CmdLineRaw()_ContextMenu()_ConvertLHWebColor()/_ConvertSHWebColor()_DesktopDimensions()_DisplayPassword()_DotNet_Load()/_DotNet_Unload()_Fibonacci()_FileCompare()_FileCompareContents()_FileNameByHandle()_FilePrefix/SRE()_FindInFile()_GetBackgroundColor()/_SetBackgroundColor()_GetConrolID()_GetCtrlClass()_GetDirectoryFormat()_GetDriveMediaType()_GetFilename()/_GetFilenameExt()_GetHardwareID()_GetIP()_GetIP_Country()_GetOSLanguage()_GetSavedSource()_GetStringSize()_GetSystemPaths()_GetURLImage()_GIFImage()_GoogleWeather()_GUICtrlCreateGroup()_GUICtrlListBox_CreateArray()_GUICtrlListView_CreateArray()_GUICtrlListView_SaveCSV()_GUICtrlListView_SaveHTML()_GUICtrlListView_SaveTxt()_GUICtrlListView_SaveXML()_GUICtrlMenu_Recent()_GUICtrlMenu_SetItemImage()_GUICtrlTreeView_CreateArray()_GUIDisable()_GUIImageList_SetIconFromHandle()_GUIRegisterMsg()_GUISetIcon()_Icon_Clear()/_Icon_Set()_IdleTime()_InetGet()_InetGetGUI()_InetGetProgress()_IPDetails()_IsFileOlder()_IsGUID()_IsHex()_IsPalindrome()_IsRegKey()_IsStringRegExp()_IsSystemDrive()_IsUPX()_IsValidType()_IsWebColor()_Language()_Log()_MicrosoftInternetConnectivity()_MSDNDataType()_PathFull/GetRelative/Split()_PathSplitEx()_PrintFromArray()_ProgressSetMarquee()_ReDim()_RockPaperScissors()/_RockPaperScissorsLizardSpock()_ScrollingCredits_SelfDelete()_SelfRename()_SelfUpdate()_SendTo()_ShellAll()_ShellFile()_ShellFolder()_SingletonHWID()_SingletonPID()_Startup()_StringCompact()_StringIsValid()_StringRegExpMetaCharacters()_StringReplaceWholeWord()_StringStripChars()_Temperature()_TrialPeriod()_UKToUSDate()/_USToUKDate()_WinAPI_Create_CTL_CODE()_WinAPI_CreateGUID()_WMIDateStringToDate()/_DateToWMIDateString()Au3 script parsingAutoIt SearchAutoIt3 PortableAutoIt3WrapperToPragmaAutoItWinGetTitle()/AutoItWinSetTitle()CodingDirToHTML5FileInstallrFileReadLastChars()GeoIP databaseGUI - Only Close ButtonGUI ExamplesGUICtrlDeleteImage()GUICtrlGetBkColor()GUICtrlGetStyle()GUIEventsGUIGetBkColor()Int_Parse() & Int_TryParse()IsISBN()LockFile()Mapping CtrlIDsOOP in AutoItParseHeadersToSciTE()PasswordValidPasteBinPosts Per DayPreExpandProtect GlobalsQueue()Resource UpdateResourcesExSciTE JumpSettings INISHELLHOOKShunting-YardSignature CreatorStack()Stopwatch()StringAddLF()/StringStripLF()StringEOLToCRLF()VSCROLLWM_COPYDATAMore Examples...

Updated: 22/04/2018

Posted

Danyfirex can vouch for this, the WinHttp UDF might be a good option to look into as well. You know if your purpose is to improve with AutoIt.

UDF List:

 
_AdapterConnections()_AlwaysRun()_AppMon()_AppMonEx()_ArrayFilter/_ArrayReduce_BinaryBin()_CheckMsgBox()_CmdLineRaw()_ContextMenu()_ConvertLHWebColor()/_ConvertSHWebColor()_DesktopDimensions()_DisplayPassword()_DotNet_Load()/_DotNet_Unload()_Fibonacci()_FileCompare()_FileCompareContents()_FileNameByHandle()_FilePrefix/SRE()_FindInFile()_GetBackgroundColor()/_SetBackgroundColor()_GetConrolID()_GetCtrlClass()_GetDirectoryFormat()_GetDriveMediaType()_GetFilename()/_GetFilenameExt()_GetHardwareID()_GetIP()_GetIP_Country()_GetOSLanguage()_GetSavedSource()_GetStringSize()_GetSystemPaths()_GetURLImage()_GIFImage()_GoogleWeather()_GUICtrlCreateGroup()_GUICtrlListBox_CreateArray()_GUICtrlListView_CreateArray()_GUICtrlListView_SaveCSV()_GUICtrlListView_SaveHTML()_GUICtrlListView_SaveTxt()_GUICtrlListView_SaveXML()_GUICtrlMenu_Recent()_GUICtrlMenu_SetItemImage()_GUICtrlTreeView_CreateArray()_GUIDisable()_GUIImageList_SetIconFromHandle()_GUIRegisterMsg()_GUISetIcon()_Icon_Clear()/_Icon_Set()_IdleTime()_InetGet()_InetGetGUI()_InetGetProgress()_IPDetails()_IsFileOlder()_IsGUID()_IsHex()_IsPalindrome()_IsRegKey()_IsStringRegExp()_IsSystemDrive()_IsUPX()_IsValidType()_IsWebColor()_Language()_Log()_MicrosoftInternetConnectivity()_MSDNDataType()_PathFull/GetRelative/Split()_PathSplitEx()_PrintFromArray()_ProgressSetMarquee()_ReDim()_RockPaperScissors()/_RockPaperScissorsLizardSpock()_ScrollingCredits_SelfDelete()_SelfRename()_SelfUpdate()_SendTo()_ShellAll()_ShellFile()_ShellFolder()_SingletonHWID()_SingletonPID()_Startup()_StringCompact()_StringIsValid()_StringRegExpMetaCharacters()_StringReplaceWholeWord()_StringStripChars()_Temperature()_TrialPeriod()_UKToUSDate()/_USToUKDate()_WinAPI_Create_CTL_CODE()_WinAPI_CreateGUID()_WMIDateStringToDate()/_DateToWMIDateString()Au3 script parsingAutoIt SearchAutoIt3 PortableAutoIt3WrapperToPragmaAutoItWinGetTitle()/AutoItWinSetTitle()CodingDirToHTML5FileInstallrFileReadLastChars()GeoIP databaseGUI - Only Close ButtonGUI ExamplesGUICtrlDeleteImage()GUICtrlGetBkColor()GUICtrlGetStyle()GUIEventsGUIGetBkColor()Int_Parse() & Int_TryParse()IsISBN()LockFile()Mapping CtrlIDsOOP in AutoItParseHeadersToSciTE()PasswordValidPasteBinPosts Per DayPreExpandProtect GlobalsQueue()Resource UpdateResourcesExSciTE JumpSettings INISHELLHOOKShunting-YardSignature CreatorStack()Stopwatch()StringAddLF()/StringStripLF()StringEOLToCRLF()VSCROLLWM_COPYDATAMore Examples...

Updated: 22/04/2018

Posted (edited)

Danyfirex can vouch for this, the WinHttp UDF might be a good option to look into as well. You know if your purpose is to improve with AutoIt.

Sure, I can.

@guinness

You should make a UDF using winHttp or share 

source code lol  :D

saludos  guinness  :ph34r:

Edited by Danyfirex
Posted (edited)

Sure, I can.

@guinness

You should make a UDF using winHttp or share 

source code lol  :D

saludos  guinness  :ph34r:

It's the only thing I haven't shared on here, I think I'm allowed this one pass.

Edited by guinness

UDF List:

 
_AdapterConnections()_AlwaysRun()_AppMon()_AppMonEx()_ArrayFilter/_ArrayReduce_BinaryBin()_CheckMsgBox()_CmdLineRaw()_ContextMenu()_ConvertLHWebColor()/_ConvertSHWebColor()_DesktopDimensions()_DisplayPassword()_DotNet_Load()/_DotNet_Unload()_Fibonacci()_FileCompare()_FileCompareContents()_FileNameByHandle()_FilePrefix/SRE()_FindInFile()_GetBackgroundColor()/_SetBackgroundColor()_GetConrolID()_GetCtrlClass()_GetDirectoryFormat()_GetDriveMediaType()_GetFilename()/_GetFilenameExt()_GetHardwareID()_GetIP()_GetIP_Country()_GetOSLanguage()_GetSavedSource()_GetStringSize()_GetSystemPaths()_GetURLImage()_GIFImage()_GoogleWeather()_GUICtrlCreateGroup()_GUICtrlListBox_CreateArray()_GUICtrlListView_CreateArray()_GUICtrlListView_SaveCSV()_GUICtrlListView_SaveHTML()_GUICtrlListView_SaveTxt()_GUICtrlListView_SaveXML()_GUICtrlMenu_Recent()_GUICtrlMenu_SetItemImage()_GUICtrlTreeView_CreateArray()_GUIDisable()_GUIImageList_SetIconFromHandle()_GUIRegisterMsg()_GUISetIcon()_Icon_Clear()/_Icon_Set()_IdleTime()_InetGet()_InetGetGUI()_InetGetProgress()_IPDetails()_IsFileOlder()_IsGUID()_IsHex()_IsPalindrome()_IsRegKey()_IsStringRegExp()_IsSystemDrive()_IsUPX()_IsValidType()_IsWebColor()_Language()_Log()_MicrosoftInternetConnectivity()_MSDNDataType()_PathFull/GetRelative/Split()_PathSplitEx()_PrintFromArray()_ProgressSetMarquee()_ReDim()_RockPaperScissors()/_RockPaperScissorsLizardSpock()_ScrollingCredits_SelfDelete()_SelfRename()_SelfUpdate()_SendTo()_ShellAll()_ShellFile()_ShellFolder()_SingletonHWID()_SingletonPID()_Startup()_StringCompact()_StringIsValid()_StringRegExpMetaCharacters()_StringReplaceWholeWord()_StringStripChars()_Temperature()_TrialPeriod()_UKToUSDate()/_USToUKDate()_WinAPI_Create_CTL_CODE()_WinAPI_CreateGUID()_WMIDateStringToDate()/_DateToWMIDateString()Au3 script parsingAutoIt SearchAutoIt3 PortableAutoIt3WrapperToPragmaAutoItWinGetTitle()/AutoItWinSetTitle()CodingDirToHTML5FileInstallrFileReadLastChars()GeoIP databaseGUI - Only Close ButtonGUI ExamplesGUICtrlDeleteImage()GUICtrlGetBkColor()GUICtrlGetStyle()GUIEventsGUIGetBkColor()Int_Parse() & Int_TryParse()IsISBN()LockFile()Mapping CtrlIDsOOP in AutoItParseHeadersToSciTE()PasswordValidPasteBinPosts Per DayPreExpandProtect GlobalsQueue()Resource UpdateResourcesExSciTE JumpSettings INISHELLHOOKShunting-YardSignature CreatorStack()Stopwatch()StringAddLF()/StringStripLF()StringEOLToCRLF()VSCROLLWM_COPYDATAMore Examples...

Updated: 22/04/2018

Posted

Go back over that UDF again as I can seem some mistakes. For example you're returning but never closing the open handles. 

One method to adopt would be this... because you have an open handle so there really is no need to close it and then open it everytime.

UDF List:

 
_AdapterConnections()_AlwaysRun()_AppMon()_AppMonEx()_ArrayFilter/_ArrayReduce_BinaryBin()_CheckMsgBox()_CmdLineRaw()_ContextMenu()_ConvertLHWebColor()/_ConvertSHWebColor()_DesktopDimensions()_DisplayPassword()_DotNet_Load()/_DotNet_Unload()_Fibonacci()_FileCompare()_FileCompareContents()_FileNameByHandle()_FilePrefix/SRE()_FindInFile()_GetBackgroundColor()/_SetBackgroundColor()_GetConrolID()_GetCtrlClass()_GetDirectoryFormat()_GetDriveMediaType()_GetFilename()/_GetFilenameExt()_GetHardwareID()_GetIP()_GetIP_Country()_GetOSLanguage()_GetSavedSource()_GetStringSize()_GetSystemPaths()_GetURLImage()_GIFImage()_GoogleWeather()_GUICtrlCreateGroup()_GUICtrlListBox_CreateArray()_GUICtrlListView_CreateArray()_GUICtrlListView_SaveCSV()_GUICtrlListView_SaveHTML()_GUICtrlListView_SaveTxt()_GUICtrlListView_SaveXML()_GUICtrlMenu_Recent()_GUICtrlMenu_SetItemImage()_GUICtrlTreeView_CreateArray()_GUIDisable()_GUIImageList_SetIconFromHandle()_GUIRegisterMsg()_GUISetIcon()_Icon_Clear()/_Icon_Set()_IdleTime()_InetGet()_InetGetGUI()_InetGetProgress()_IPDetails()_IsFileOlder()_IsGUID()_IsHex()_IsPalindrome()_IsRegKey()_IsStringRegExp()_IsSystemDrive()_IsUPX()_IsValidType()_IsWebColor()_Language()_Log()_MicrosoftInternetConnectivity()_MSDNDataType()_PathFull/GetRelative/Split()_PathSplitEx()_PrintFromArray()_ProgressSetMarquee()_ReDim()_RockPaperScissors()/_RockPaperScissorsLizardSpock()_ScrollingCredits_SelfDelete()_SelfRename()_SelfUpdate()_SendTo()_ShellAll()_ShellFile()_ShellFolder()_SingletonHWID()_SingletonPID()_Startup()_StringCompact()_StringIsValid()_StringRegExpMetaCharacters()_StringReplaceWholeWord()_StringStripChars()_Temperature()_TrialPeriod()_UKToUSDate()/_USToUKDate()_WinAPI_Create_CTL_CODE()_WinAPI_CreateGUID()_WMIDateStringToDate()/_DateToWMIDateString()Au3 script parsingAutoIt SearchAutoIt3 PortableAutoIt3WrapperToPragmaAutoItWinGetTitle()/AutoItWinSetTitle()CodingDirToHTML5FileInstallrFileReadLastChars()GeoIP databaseGUI - Only Close ButtonGUI ExamplesGUICtrlDeleteImage()GUICtrlGetBkColor()GUICtrlGetStyle()GUIEventsGUIGetBkColor()Int_Parse() & Int_TryParse()IsISBN()LockFile()Mapping CtrlIDsOOP in AutoItParseHeadersToSciTE()PasswordValidPasteBinPosts Per DayPreExpandProtect GlobalsQueue()Resource UpdateResourcesExSciTE JumpSettings INISHELLHOOKShunting-YardSignature CreatorStack()Stopwatch()StringAddLF()/StringStripLF()StringEOLToCRLF()VSCROLLWM_COPYDATAMore Examples...

Updated: 22/04/2018

Posted (edited)

Go back over that UDF again as I can seem some mistakes. For example you're returning but never closing the open handles. 

One method to adopt would be this... because you have an open handle so there really is no need to close it and then open it everytime.

Hi guinness, 

Thank you for your constructive criticism. 

I have made the udf so you only have to open the handle once in a session and then can close it at the end as you suggested, 

this makes it a lot better, Thank You again

Edited by mrflibblehat

[font="'courier new', courier, monospace;"]Pastebin UDF | Prowl UDF[/font]

Posted

Another point, Global variables should be declared outside of functions, so add the following to the top and remove the Global keywords from the open function.

Global $vOpen = 0, $vConnect = 0

UDF List:

 
_AdapterConnections()_AlwaysRun()_AppMon()_AppMonEx()_ArrayFilter/_ArrayReduce_BinaryBin()_CheckMsgBox()_CmdLineRaw()_ContextMenu()_ConvertLHWebColor()/_ConvertSHWebColor()_DesktopDimensions()_DisplayPassword()_DotNet_Load()/_DotNet_Unload()_Fibonacci()_FileCompare()_FileCompareContents()_FileNameByHandle()_FilePrefix/SRE()_FindInFile()_GetBackgroundColor()/_SetBackgroundColor()_GetConrolID()_GetCtrlClass()_GetDirectoryFormat()_GetDriveMediaType()_GetFilename()/_GetFilenameExt()_GetHardwareID()_GetIP()_GetIP_Country()_GetOSLanguage()_GetSavedSource()_GetStringSize()_GetSystemPaths()_GetURLImage()_GIFImage()_GoogleWeather()_GUICtrlCreateGroup()_GUICtrlListBox_CreateArray()_GUICtrlListView_CreateArray()_GUICtrlListView_SaveCSV()_GUICtrlListView_SaveHTML()_GUICtrlListView_SaveTxt()_GUICtrlListView_SaveXML()_GUICtrlMenu_Recent()_GUICtrlMenu_SetItemImage()_GUICtrlTreeView_CreateArray()_GUIDisable()_GUIImageList_SetIconFromHandle()_GUIRegisterMsg()_GUISetIcon()_Icon_Clear()/_Icon_Set()_IdleTime()_InetGet()_InetGetGUI()_InetGetProgress()_IPDetails()_IsFileOlder()_IsGUID()_IsHex()_IsPalindrome()_IsRegKey()_IsStringRegExp()_IsSystemDrive()_IsUPX()_IsValidType()_IsWebColor()_Language()_Log()_MicrosoftInternetConnectivity()_MSDNDataType()_PathFull/GetRelative/Split()_PathSplitEx()_PrintFromArray()_ProgressSetMarquee()_ReDim()_RockPaperScissors()/_RockPaperScissorsLizardSpock()_ScrollingCredits_SelfDelete()_SelfRename()_SelfUpdate()_SendTo()_ShellAll()_ShellFile()_ShellFolder()_SingletonHWID()_SingletonPID()_Startup()_StringCompact()_StringIsValid()_StringRegExpMetaCharacters()_StringReplaceWholeWord()_StringStripChars()_Temperature()_TrialPeriod()_UKToUSDate()/_USToUKDate()_WinAPI_Create_CTL_CODE()_WinAPI_CreateGUID()_WMIDateStringToDate()/_DateToWMIDateString()Au3 script parsingAutoIt SearchAutoIt3 PortableAutoIt3WrapperToPragmaAutoItWinGetTitle()/AutoItWinSetTitle()CodingDirToHTML5FileInstallrFileReadLastChars()GeoIP databaseGUI - Only Close ButtonGUI ExamplesGUICtrlDeleteImage()GUICtrlGetBkColor()GUICtrlGetStyle()GUIEventsGUIGetBkColor()Int_Parse() & Int_TryParse()IsISBN()LockFile()Mapping CtrlIDsOOP in AutoItParseHeadersToSciTE()PasswordValidPasteBinPosts Per DayPreExpandProtect GlobalsQueue()Resource UpdateResourcesExSciTE JumpSettings INISHELLHOOKShunting-YardSignature CreatorStack()Stopwatch()StringAddLF()/StringStripLF()StringEOLToCRLF()VSCROLLWM_COPYDATAMore Examples...

Updated: 22/04/2018

Posted

You're welcome and sorry if it seems as though I'm singling you out.

UDF List:

 
_AdapterConnections()_AlwaysRun()_AppMon()_AppMonEx()_ArrayFilter/_ArrayReduce_BinaryBin()_CheckMsgBox()_CmdLineRaw()_ContextMenu()_ConvertLHWebColor()/_ConvertSHWebColor()_DesktopDimensions()_DisplayPassword()_DotNet_Load()/_DotNet_Unload()_Fibonacci()_FileCompare()_FileCompareContents()_FileNameByHandle()_FilePrefix/SRE()_FindInFile()_GetBackgroundColor()/_SetBackgroundColor()_GetConrolID()_GetCtrlClass()_GetDirectoryFormat()_GetDriveMediaType()_GetFilename()/_GetFilenameExt()_GetHardwareID()_GetIP()_GetIP_Country()_GetOSLanguage()_GetSavedSource()_GetStringSize()_GetSystemPaths()_GetURLImage()_GIFImage()_GoogleWeather()_GUICtrlCreateGroup()_GUICtrlListBox_CreateArray()_GUICtrlListView_CreateArray()_GUICtrlListView_SaveCSV()_GUICtrlListView_SaveHTML()_GUICtrlListView_SaveTxt()_GUICtrlListView_SaveXML()_GUICtrlMenu_Recent()_GUICtrlMenu_SetItemImage()_GUICtrlTreeView_CreateArray()_GUIDisable()_GUIImageList_SetIconFromHandle()_GUIRegisterMsg()_GUISetIcon()_Icon_Clear()/_Icon_Set()_IdleTime()_InetGet()_InetGetGUI()_InetGetProgress()_IPDetails()_IsFileOlder()_IsGUID()_IsHex()_IsPalindrome()_IsRegKey()_IsStringRegExp()_IsSystemDrive()_IsUPX()_IsValidType()_IsWebColor()_Language()_Log()_MicrosoftInternetConnectivity()_MSDNDataType()_PathFull/GetRelative/Split()_PathSplitEx()_PrintFromArray()_ProgressSetMarquee()_ReDim()_RockPaperScissors()/_RockPaperScissorsLizardSpock()_ScrollingCredits_SelfDelete()_SelfRename()_SelfUpdate()_SendTo()_ShellAll()_ShellFile()_ShellFolder()_SingletonHWID()_SingletonPID()_Startup()_StringCompact()_StringIsValid()_StringRegExpMetaCharacters()_StringReplaceWholeWord()_StringStripChars()_Temperature()_TrialPeriod()_UKToUSDate()/_USToUKDate()_WinAPI_Create_CTL_CODE()_WinAPI_CreateGUID()_WMIDateStringToDate()/_DateToWMIDateString()Au3 script parsingAutoIt SearchAutoIt3 PortableAutoIt3WrapperToPragmaAutoItWinGetTitle()/AutoItWinSetTitle()CodingDirToHTML5FileInstallrFileReadLastChars()GeoIP databaseGUI - Only Close ButtonGUI ExamplesGUICtrlDeleteImage()GUICtrlGetBkColor()GUICtrlGetStyle()GUIEventsGUIGetBkColor()Int_Parse() & Int_TryParse()IsISBN()LockFile()Mapping CtrlIDsOOP in AutoItParseHeadersToSciTE()PasswordValidPasteBinPosts Per DayPreExpandProtect GlobalsQueue()Resource UpdateResourcesExSciTE JumpSettings INISHELLHOOKShunting-YardSignature CreatorStack()Stopwatch()StringAddLF()/StringStripLF()StringEOLToCRLF()VSCROLLWM_COPYDATAMore Examples...

Updated: 22/04/2018

  • 4 years later...
Posted

Hi,

I don't want to revive a zombie but this (and another https://www.autoitscript.com/forum/topic/123879-pastebin-api-winhttpau3/#comment-1015397) thread is the only one dealing with pastebin.

There is something new. The api is working with ssl only since august 1st. So you must change the winhttp requests.

Regards, Conrad

 

SciTE4AutoIt = 3.7.3.0   AutoIt = 3.3.14.2   AutoItX64 = 0   OS = Win_10   Build = 19044   OSArch = X64   Language = 0407/german
H:\...\AutoIt3\SciTE     H:\...\AutoIt3      H:\...\AutoIt3\Include     (H:\ = Network Drive)

   88x31.png  Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind.

  • 4 months later...
Posted (edited)

It's a nice UDF, but 

vPublicity

is not working, if you set it to 1 it still won't be hidden for the public, it won't be private. I also tried to set it to 2, but no matter what, I can't get it private.

Edited by legend
  • 4 years later...
Posted

So guess what - I am trying to make this work, but I am getting

Created Paste: Bad API request, use POST request, not GET

something has changed somewhere which broke this I suppose?

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...