Sure, this is what I had. Haven't touched it since the original playing around since the GUI issues discouraged me too much and got busy with other things. This would definitely need a lot of cleaning up and more error handling, but this was a working model... I tried to take out everything except the parts that really pertain to the authorization and using it. You can piece it together depending on your application.
Func Authorize($verifier_input = "")
If $verifier_input = "" Then
; initial auth setup
$path = "/oauth/request_token"
$postdata = "oauth_consumer_key=" & $oauth_consumer_key
$header = 'Authorization: OAuth oauth_consumer_key="' & $oauth_consumer_key & '"'
$header &= ',oauth_signature_method="PLAINTEXT"'
$header &= ',oauth_timestamp="' & Timestamp() & '"'
$header &= ',oauth_nonce="' & Nonce() & '"'
$header &= ',oauth_signature="' & $oauth_signature & '"'
$response = MakeRequest("POST", $path, $postdata, $header)
SetTokenStrings($response[1])
$path = "/oauth/authorize"
$postdata = $response[1]
$header = ""
$link = "https://" & $host & $path & "?" & $postdata
ShellExecute($link)
Else
; returning setup, process verifier
$oauth_verifier = $verifier_input
$path = "/oauth/access_token"
$postdata = "oauth_consumer_key=" & $oauth_consumer_key
$header = 'Authorization: OAuth oauth_consumer_key="' & $oauth_consumer_key & '"'
$header &= ',oauth_token="' & $oauth_token & '"'
$header &= ',oauth_signature_method="PLAINTEXT"'
$header &= ',oauth_timestamp="' & Timestamp() & '"'
$header &= ',oauth_nonce="' & Nonce() & '"'
$header &= ',oauth_signature="' & $oauth_signature & '"'
$header &= ',oauth_verifier="' & $oauth_verifier & '"'
$response = MakeRequest("POST", $path, $postdata, $header)
SetTokenStrings($response[1])
IniWrite($ini, "auth", "tk", $oauth_token)
IniWrite($ini, "auth", "sig", $oauth_signature)
AuthStuff("HIDE")
Refresh()
EndIf
EndFunc
Func Refresh()
; make sure it isn't too recent first
If Timestamp() - $last_refresh > 44 Then
$last_refresh = Timestamp()
$path = "/api/v1/messages.xml"
$postdata = ""
$header = 'Authorization: OAuth oauth_consumer_key="' & $oauth_consumer_key & '"'
$header &= ',oauth_token="' & $oauth_token & '"'
$header &= ',oauth_signature_method="PLAINTEXT"'
$header &= ',oauth_timestamp="' & Timestamp() & '"'
$header &= ',oauth_nonce="' & Nonce() & '"'
$header &= ',oauth_signature="' & $oauth_signature & '"'
$response = MakeRequest("GET", $path, $postdata, $header)
$last_xml = $response[1]
Else
MsgBox(0, "", "Too soon to refresh!")
EndIf
_XMLLoadXML($last_xml)
$nNodes = _XMLGetNodeCount("/response/messages/message")
For $i = 1 To $nNodes
$body = _XMLGetValue("/response/messages/message[" & $i & "]/body/plain")
$text = $body[1]
Next
EndFunc
Func Post($s)
$path = "/api/v1/messages.xml"
$postdata = "body=" & $s ; need to encode this
$header = 'Authorization: OAuth oauth_consumer_key="' & $oauth_consumer_key & '"'
$header &= ',oauth_token="' & $oauth_token & '"'
$header &= ',oauth_signature_method="PLAINTEXT"'
$header &= ',oauth_timestamp="' & Timestamp() & '"'
$header &= ',oauth_nonce="' & Nonce() & '"'
$header &= ',oauth_signature="' & $oauth_signature & '"'
$header &= ' Content-Type: application/x-www-form-urlencoded'
$response = MakeRequest("POST", $path, $postdata, $header)
_ArrayDisplay($response)
;~ Refresh()
EndFunc
Func Startup()
; see if ini file is there first
If Not FileExists($ini) Then
FileOpen($ini, 10)
FileClose($ini)
EndIf
$temp_token = IniRead($ini, "auth", "tk", "")
$temp_signature = IniRead($ini, "auth", "sig", "")
If $temp_token = "" Then
; if blank, do initial authorization first
AuthStuff("SHOW")
MsgBox(16, "Initial setup required", "It appears that you have not set up authorization.")
Authorize()
Else
$oauth_token = $temp_token
$oauth_signature = $temp_signature
;~ Refresh()
EndIf
EndFunc
Func MakeRequest($req_type, $req_path, $req_postdata, $req_header, $req_return_type = 1)
; set up connection, pass arguments and return something ... options for returning?
Local $t_or_f
Switch $req_return_type
Case 1
; default return type
$t_or_f = "True"
Case 2
$t_or_f = "False"
EndSwitch
Local $session = _WinHttpOpen()
Local $connection = _WinHttpConnect($session, $host)
Local $response = _WinHttpSimpleSSLRequest($connection, $req_type, $req_path, $req_postdata, Default, $req_header, $t_or_f)
_WinHttpCloseHandle($connection)
_WinHttpCloseHandle($session)
Return $response
EndFunc
Func SetTokenStrings($s)
; we need oauth_token and oauth_token_secret from string and might be out of order
$aResponse = StringSplit($s, "&")
For $i = 0 To UBound($aResponse) -1
If StringInStr($aResponse[$i], "oauth_token=") Then
$oauth_token = StringReplace($aResponse[$i], "oauth_token=", "")
ElseIf StringInStr($aResponse[$i], "oauth_token_secret=") Then
$oauth_token_secret = StringReplace($aResponse[$i], "oauth_token_secret=", "")
EndIf
Next
$oauth_signature = $oauth_consumer_secret & "%26" & $oauth_token_secret
EndFunc
Func Timestamp()
Local $rslt = DllCall("msvcrt.dll", "int:cdecl", "time", "int", 0)
If @error = 0 Then Return $rslt[0]
Return -1
EndFunc
Func Nonce()
Return Random(100000000, 999999999, 1)
EndFunc