eversor
eversor

Reputation: 3073

Posting tweets from vb.net

How could I post custom tweets on my twitter account using vb.net?

If is not possible, which I doubt, is there any way to achive this with c# or javascript?

Upvotes: 4

Views: 2919

Answers (3)

Ed E
Ed E

Reputation: 1

A super easy way of doing this is by using IFTTT and my IFTTT Maker.net libary

First, in IFTTT create a new recipe that's triggered by the Maker channel and name the event "tweet_now".

Then, select the Twitter engine and click "Post a tweet", remove everything from the input box and replace it with {{value1}} and click create recipe.

After that, in Visual studio, add ifttt.vb to your project. Now for the code:

      Try
    makechannel.scode = "your account ID"
    makechannel.fireevent("tweet_now", "Tweet text", "", "")
   'code goes here if done
    Catch ex As Exception
        'code goes here if it fails
    End Try

Then fill in your account ID. You can find it at ifttt.com/maker

And that's it!

Upvotes: 0

Joe Mayo
Joe Mayo

Reputation: 7513

You can do it in LINQ to Twitter like this:

    Dim credentials As IOAuthCredentials = New InMemoryCredentials
    credentials.ConsumerKey = "xxx"
    credentials.ConsumerSecret = "xxx"
    credentials.OAuthToken = "xxx"
    credentials.AccessToken = "xxx"

    Dim auth As PinAuthorizer = New PinAuthorizer()
    auth.Credentials = credentials

    Dim twitterCtx As TwitterContext = New TwitterContext(auth)
    twitterCtx.UpdateStatus(statusMsg)

and if you want to perform a query, you can do it like this:

    Dim queryResults = _
        From search In twitterCtx.Search _
        Where search.Type = SearchType.Search _
        And search.Query = "LINQ to Twitter"

More info here: http://linqtotwitter.codeplex.com/.

Upvotes: 1

sloth
sloth

Reputation: 101072

You can use the twitterizer library.


Here's an example how to use it:

Dim tokens As New OAuthTokens()
tokens.AccessToken = "XXX"
tokens.AccessTokenSecret = "XXX"
tokens.ConsumerKey = "XXX"
tokens.ConsumerSecret = "XXX"

Dim tweetResponse As TwitterResponse(Of TwitterStatus) = TwitterStatus.Update(tokens, "Hello, #Twitterizer")

If tweetResponse.Result = RequestResult.Success Then
        ' Tweet posted successfully!
Else
        ' Something bad happened
End If

BTW, here's a list of avaiable twitter libraries (but it's not 100% up-to-date).

Upvotes: 2

Related Questions