Twitter VB
Definition: A "wrapper" is essentially a chunk of code (class, dll, etc.) that you will be able to download, drop into your project, and be pretty much ready to go quickly and efficiently . These "wrappers" will handle all the details of the connections, parameters, and interface for you so that you can focus on just using the object(s).
this is for anyone looking to increase their skills and if your bored, If you feel like developing a Desktop Widget, A App, Or a notification service. This is a Twitter API .net Dll Wrapper. Essentially it allows you to use Twitter API without having to lay down any of the annoying (sometimes time consuming) ground work {which for twitter can be annoying especially now that authorization using OAuth is all that is excepted when creating desktop or web applications}, Simply add the .dll as a reference, and create your application using the API
What You Need.
1. A Twitter API Key
Click Here
2. Visual Basic (or studio if using with C#, Web Developer, etc)
3. The .dll attachment located in this thread
Once you have registered your application and receive your Secret Keys you can begin creating your project.
Among a-lot of other things Twitter VB has
A implementation of OAuth for desktop and web applications. (Which is now the only acceptable way to access twitter from a 3rd party app)
Supports Twitter's new "retweet" and "list" functions.
Can upload photos to TwicPic and TweetPhoto.
Provides access to Url shorteners.
100% .NET code, implemented to be compatible with version 2.0 or higher of the .NET Framework. \
it can be used with any .NET-compliant language (C#, C, Delphi, etc).
Here is a quick tutorial(ish), Quickly made a small project to display how to use it.
After adding the dll as a reference
Code:
Imports TwitterVB2
Imports TwitterAPIException
'TwitterAPIException is used to display the error TwitterAPI is displaying (as opposed to a general error from your application ,
Code:
Try
'Code
Catch Ex as TwitterAPIException
'display error
end try
Importing Twittervb2 gives you full access to the wrapper, You may see twitter, but that is outdated and uses normal login features which is no longer accepted.
At this point you will have intellisense to guide you. However that API Requires your "Secrets" to gain access to the Twitter API.
First we need to ask the user permission for this app to use their account
Code:
Public TwLog as New TwitterAPI
'On button click event or form load event
'This will generate a unigue url for the user to use your registered application
Dim AuthUrl As String = tw.GetAuthorizationLink(ConsumerKey, ConsumerKeySecret)
Note: Both ConsumerKey and ConsumerKeySecret are provided by twitter to your development account, don't share this information with anyone as it is used to identify you as a (twitter app) developer as much as it is to gain access to the API.
Once you have a generated URL (which you never need to know, Unless you have some development issues, then maybe you can create a admin part to the application for debugging where all twitter API generated info is stored , like a database for debugging)
Use the URL either in a 3rd party browser or in a browser in your application (or if your not lazy like me, user some parsing to grab the information and cleanly add it to the application)
Code:
Webbrowser1.navigate(AuthUrl)
The user will then be asked to login and authorize the application.
Here are some screenshots of the process
Login from in app webbrowser
[IMG]https://i111.photobucke*****m/albums/n121/golmor/twitter1.jpg[/IMG]
Authorization screen
[IMG]https://i111.photobucke*****m/albums/n121/golmor/twitter2.jpg[/IMG]
Now we need to verify the pin is correct
"Ask Twitter to confirm"
'Allow the user to enter the pin number.
Code:
Dim Validate As Boolean = TwLog.ValidatePIN(Textbox1.text)
If it is valid then
Code:
If Validate Then
Dim OAuthToken as String = tw.OAuth_Token()
Dim OAuthTokenSecret as String = tw.OAuth_TokenSecret()
End If
OauthToken and OauthTokenSecet is generated by Twitter API , so we will just pass the information without knowing it.
That's pretty much it.
To update status use
Code:
TwLog.AuthenticateWith(ConsumerKey,ConsumerKeySecret,OAuthToken,OAuthTokenSecret)
TwLog.Update(Textbox2.text)
remember you must hardcode your consumerkey and consumerkeysecret, Oauthtoken and Oauthtokensecret are handled "on the fly" so you can leave them as they are.
'Again you can really just parse the information and make this all automatic, just really to lazy.
Get Tweets from homepage
Code:
twlog.AuthenticateWith("consumerkey","consumersecret","oauthtoken","tokensecret")
For Each tweet As TwitterStatus In twlog.HomeTimeline()
' then pass the information to a listbox or similar
Next
for photos you will need a API for either https://twitpic.com/ or https://plixi.com/
Plus the user is required to login from your app because username and password will be required.
Code:
twlog.AuthenticateWith("consumerkey","consumersecret","oauthtoken","oauthtokensecret")
twlog.TweetPhotoUpload("C:\filelocation\Image.jpg", textbox1.text, Username.text, Password.Text", "tweet photo API key")
If you would like to user to be able to read direct messages.
Code:
twlog.AuthenticateWith("consumerkey","consumersecret","oauthtoken","oauthtokensecret")
For Each message As TwitterDirectMessage In twlog.DirectMessages
'then pass the data to a listbox or something (message.SenderScreenName & " : " & message.Text)
Send a message to a specific account (direct message a user)
Code:
twlog.AuthenticateWith("consumerkey","consumersecret","oauthtoken","tokensecret")
twlog.SendDirectMessage("Twitter UserName to message", "Your Message")
Read a specific users tweets.
Code:
twlog.AuthenticateWith("consumerkey","consumersecret","oauthtoken","oauthtokensecret")
For Each tweet As TwitterStatus In twlog.UserTimeline("Twitter UserName")
'Pass the information to a listbox or whatever (tweet.User.ScreenName & " : " & tweet.Text)
Hope this helps, Have Fun.
'This wrapper is part of the twittervb project over at codeplex.
____________________________
Virus Scan Of Attached File
VirusTotal - Free Online Virus, Malware and URL Scanner
https://virusscan.jotti.org/en/scanre...2c35fad8934fed