Windows Mobile 6 and twitter
I'm trying to implement Twitter into a mobile开发者_运维技巧 game that I'm developing and having difficulty with using the available libraries. Could someone explain how I use a library such as nTwitter on the .net compact framework 3.5 and windows mobile 6 professional SDK Thanks in advance for any help Tom
Twitter can be controlled by simple authorized web requests. To do this you can use System.Net.HttpWebRequest from .NET Framework.
The example below demonstrates how to post a status to Twitter:
public void SubmitUserStatus(string username, string password, string tweet)
{
// encode the username/password
string user = Convert.ToBase64String(System.Text.Encoding.UTF8.GetBytes(username + ":" + password));
// determine what we want to upload as a status
byte[] bytes = System.Text.Encoding.ASCII.GetBytes("status=" + tweet);
// connect with the update page
HttpWebRequest request = (HttpWebRequest)WebRequest.Create("http://twitter.com/statuses/update.xml");
// set the method to POST
request.Method = "POST";
request.ServicePoint.Expect100Continue = false;
// set the authorisation levels
request.Headers.Add("Authorization", "Basic " + user);
request.ContentType = "application/x-www-form-urlencoded";
// set the length of the content
request.ContentLength = bytes.Length;
// set up the stream
Stream reqStream = request.GetRequestStream();
// write to the stream
reqStream.Write(bytes, 0, bytes.Length);
// close the stream
reqStream.Close();
}
source: http://weblogs.asp.net/wallym/archive/2009/03/25/twitter-api-submit-a-post-in-c.aspx
Also I would recommend to look at this page for ready libraries: http://dev.twitter.com/pages/libraries#csharp
精彩评论