Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How use new twitter oAuth in vbs ?

Status
Not open for further replies.

thierryd75

Technical User
Sep 17, 2010
1
FR
Hi,

I write and use this function in vbs since 2 years :

' --------------------------
' FUNCTIONS SendToTwitter
' --------------------------

Function SendToTwitter(strMessage, strUsername, strPassword)
On Error Resume Next
Dim objHTTP, result
Set objHTTP = CreateObject("Microsoft.XMLHTTP")

WScript.Echo "Post Twitter : " & " " & numligne & " " & date() & " " & time () & " " & strMessage
objHTTP.open "POST", " false, strUsername, strPassword
objHTTP.send "status=" & strMessage
result = objHTTP.responseText
If objHttp.status <> 200 Then Postageok=0 : WScript.Echo "No Post Twitter" & Len(strMessage) & Statusok Else Postageok=1 : WScript.Echo "Post Twitter OK " & Statusok End if
strMessage = ""
Set objHTTP = nothing 'Release the object
Set result = Nothing

End Function

but on 30 august 2010 twitter down this authentication

I search on web and found how and create apps oauth in twitter : (login required)
with php script fr send tweets ... here :

Marche à suivre :

1. Connectez-vous sur Twitter, puis allez sur 2. Cliquez sur “Your Apps” puis “Register a new application”
3. Remplissez les champs, n'oubliez pas de cocher “Read & Write” au lieu de “Read-only” dans “Default Access type”. Les autres informations n'ont que peu d'importance, comme “callback url” qui ne nous servira pas : mettez simplement l'adresse de votre site web par exemple.
4. Une fois l'application enregistrée, nous obtenons les clefs nécessaires par la suite : en cliquant sur les détails de votre application, vous verrez :
* Consumer key
* Consumer secret
5. puis en cliquant sur My access token, vous obtiendrez :
* Access Token (oauth_token)
* Access Token Secret (oauth_token_secret)

but i don't know use this with my vbs function because i'm not a good programmer and don't update my tweets now ????

Have you a solution please for me in vbs ? thanks a lot at all !!!
Thierry
 
>use this function in vbs since 2 years
I don't know what happens on those 2 years of the vbs of yours. But, the script is certain not correct if only you got away because it errors out, at least, just at the end and you had escaped the mal-function by fortune. There is no way it works as such at any period of time.

It should at least look something like this. Still no gurantee, depending the proper url to process the post. To an xml extension, it seems strange; but I have no way to know.
[tt]
Function SendToTwitter(strMessage, strUsername, strPassword)
[red]'[/red]On Error Resume Next
Dim objHTTP, result
Set objHTTP = CreateObject("Microsoft.XMLHTTP")
WScript.Echo "Post Twitter : " & " " & numligne & " " & date() & " " & time () & " " & strMessage
objHTTP.open "POST", "[ignore][/ignore]", false, strUsername, strPassword
objHTTP.send "status=" & [blue]escape([/blue]strMessage[blue])[/blue]
[red]'[/red]result = objHTTP.responseText
If objHttp.status <> 200 Then
Postageok=0
WScript.Echo "No Post Twitter" & Len(strMessage) & Statusok
result=""
Else
Postageok=1
WScript.Echo "Post Twitter OK " & Statusok
[blue]result=objHTTP.responseText[/blue]
End if
[red]'[/red]strMessage = ""
Set objHTTP = nothing 'Release the object
[blue]'This won't do anything, just because you have an on error resume next; it is wrong and you're fortunate to preserve result if it were a global variable to be used (but it is not global neither). Only postageok seems global.[/blue]
[red]'[/red]Set result = Nothing
[blue]'If result is some global variable (that should not be because you've dim result up there), you would be fortunate to get away and end the function there.
'If result is not global (that seems to be the case), you need to return to caller by this line, and during the 2 years, something happened to you if you think it works.[/blue]
[red]SendToTwitter=result[/red]
End Function

'for instance, the way to use it
dim s, postageok
s=SendToTwitter("some message","userx","passwordx")
'check postageok value too.
[/tt]
 
Upon re-reading my comments, they might tend to imply(?) the set result to nothing would error out, that is not what I would imply. I meant only it won't do anything, and it is contradictory in intention, and the result won't pass outside of the function and thereby died with the function as it is local to it.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top