Help Please

Mar 3, 2013 at 10:11 PM
I just started using twitter API, i want to post tweets from my own account (application owner) so that i dont have to get a PIN, how do i set this up? Currently its like this:

        Dim credentials As IOAuthCredentials = New InMemoryCredentials

        credentials.ConsumerKey = ConfigurationManager.AppSettings("twitterConsumerKey")
        credentials.ConsumerSecret = ConfigurationManager.AppSettings("twitterConsumerSecret")

        Dim auth As PinAuthorizer = New PinAuthorizer()
        auth.Credentials = credentials
        auth.GetPin = AddressOf VerifierCallback
        auth.GoToTwitterAuthorization = Function(pageLink) Process.Start(pageLink)
        auth.Authorize()

        Dim twitterCtx As TwitterContext = New TwitterContext(auth)

        twitterCtx.Log = Console.Out

        UpdateStatusDemo(twitterCtx)
how can i skip the pin verification process if i have the access token and access token secret
Coordinator
Mar 3, 2013 at 10:15 PM
Hi,

You can use the SingleUserAuthorizer instead. Here's the documentation for it:

http://linqtotwitter.codeplex.com/wikipage?title=Single%20User%20Authorization&referringTitle=Learning%20to%20use%20OAuth.

@JoeMayo
Mar 3, 2013 at 10:15 PM
Edited Mar 3, 2013 at 10:15 PM
Thanks.. I got it to work, i just defined access token of my own account, 1 question, how to post image file with the status?
Coordinator
Mar 3, 2013 at 10:17 PM
You can use twitterCtx.TweetWithMedia().

@JoeMayo
Mar 3, 2013 at 10:20 PM
I dont see tweetwithmedia in functions list, or in the whole module i cant find the media
Mar 3, 2013 at 10:47 PM
just to note i m using VB code from source code section, i am able to post tweets but i just dont see the TweetWithMedia function anywhere
Coordinator
Mar 3, 2013 at 10:53 PM
There's an example in the C# demos that might give you a better idea of how to use it.
Mar 3, 2013 at 11:34 PM
Ok i just put sometime into this and converted from C# to VB.NET if anyone ever needs, you might include in your source

Tested and working ;)
    Private Sub UpdateStatusWithMedia(ByVal twitterCtx As TwitterContext)
        Dim status As String = "Testing TweetWithMedia"
        Const PossiblySensitive = False
        Const ReplaceThisWithYourImageLocation = "F:\avatar.jpg"

        Dim mediaItems = New LinqToTwitter.Media()
        mediaItems.Data = Utilities.GetFileBytes(ReplaceThisWithYourImageLocation)
        mediaItems.FileName = "avatar.jpg"

        Dim mediaList = New List(Of Media)
        mediaList.Add(mediaItems)


        Dim tweet As LinqToTwitter.Status = twitterCtx.TweetWithMedia(status, PossiblySensitive, mediaList)

        Console.WriteLine("Media item sent - Tweet Text: " + tweet.Text)


    End Sub
Nov 23, 2013 at 12:38 PM
Hi,

forced into vb.net for a project, I tried to use your vb sub, but despite "tested and working" I get an error at

Dim mediaList = New List(Of Media)

error:

'LinqToTwitter.List' has no type parameters and so cannot have type arguments.

any idea what's causing this?
I can't find a vb.net example in the demo files for TweetWithMedia

Thx!
Coordinator
Nov 23, 2013 at 4:55 PM
Hi,

This is a namespace issue where your code is looking at the List in LinqToTwitter. Try adding an Import declaration for System.Collections.Generic.

@JoeMayo
Nov 23, 2013 at 5:08 PM
Hi Joe,

So obvious I didn't see it.
great support, works like a charm now. thx!