I am using VB.Net 3.5 and VS 2010. I have a web app that needs to send Tweets when information is made available, such as news updates, new members, etc. But I seem to be having a problem with the Trust level when I publish the application to Rackspace,my web host. I have talked to them about the trust issue but they are unwilling to change the level to Full trust for my app. Anyway here is what I have done so far.
I added all 4 required values, ConsumerKey, ConsumerSecret, OAuthToken, and OAuthTokenSecret to the web.config file in the "appSettings" section of the "configuration" section. <appSettings> <!-- 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" / > </appSettings> 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") Try twConn.AuthenticateWith(twitterKey, twitterSecret, twitterOAuthToken, twitterOAuthTokenSecret) twConn.Update(Trim(Tweet)) Catch ex As Exception lblError.Text = "Twitter Returned: " & ex.Message End Try End Sub 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=220.127.116.11, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed." If anyone has found a fix for this "Trust Level" issue please post it! -- Twitter developer documentation and resources: http://dev.twitter.com/doc API updates via Twitter: http://twitter.com/twitterapi Issues/Enhancements Tracker: http://code.google.com/p/twitter-api/issues/list Change your membership to this group: http://groups.google.com/group/twitter-development-talk