Well I have managed to clean up the code significantly. I added all 4 required values, ConsumerKey, ConsumerSecret, OAuthToken, and OAuthTokenSecret to the web.config file in the "appSettings" section of the "configuration" section.
<!-- Twitter and BitLy access keys -->
<add key="ConsumerKey" value="YOUR_CONSUMER_KEY" />
<add key="ConsumerSecret" value="YOUR_CONSUMER_SECRET_KEY" />
<add key="OAuthToken" value="YOUR_APPS_OAUTHTOKEN_KEY" />
<add key="OAuthTokenSecret" value="YOUR_APPS_OAUTHTOKEN_SECRET_KEY" />
If found that by going to twitter.com and signing into the account that is using the application, then go to the "Settings" page, go to the bottom of the page and click on the "API" menu option. Once the API page appears you will clik on the button "2", Register An App. On the right side on the new page, you will see a button "View Your Applications." If you have previously registered your app, click this button, If not fill out the appliction for a new app. Now at the View your Applications page, select the app you want to get the authorization keys for where is says "Edit Details".
Now click on the button to the right that says, "Application Detail." Here you will find your Consumer Key and your Consumer Secret Key. On the right side of this page you will see the menu option "My Access Token", click it and you will find your oauth_token and your oauth_token_secret keys!
Not that you have all the keys, put them in the "appSettings" section of the web.config file.
Add "Dim twConn As New TwitterVB2.TwitterAPI" at the top of the page.
I then created a subroutine where I pass in the Tweet:
Public Sub PostOnTwitter(ByVal Tweet As String)
'Retrieve Keys from web.config
Dim twitterKey As String = System.Configuration.ConfigurationManager.AppSettings("ConsumerKey")
Dim twitterSecret As String = System.Configuration.ConfigurationManager.AppSettings("ConsumerSecret")
Dim twitterOAuthToken As String = System.Configuration.ConfigurationManager.AppSettings("OAuthToken")
Dim twitterOAuthTokenSecret As String = System.Configuration.ConfigurationManager.AppSettings("OAuthTokenSecret")
twConn.AuthenticateWith(twitterKey, twitterSecret, twitterOAuthToken, twitterOAuthTokenSecret)
Catch ex As Exception
lblError.Text = "Twitter Returned: " & ex.Message
This code works great in an enviornment that allows at least a "Medium" trust level. However it appears that many of the "new" hosting envrionments such as "Cloud Hosting" and others do not allow this trust level automatically!
However if the trust level is less than "Full" on your host you will likely receive the error message: "Twitter Returned: Request for the permission of type 'System.Security.Permissions.SecurityPermission, mscorlib, Version=184.108.40.206, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed."
If anyone has found a fix for this "Trust Level" issue please post it!