1

我正在尝试将Twitter应用到我正在开发的移动游戏中,并且难以使用可用的库。有人可以解释我如何在.net compact framework 3.5和windows mobile 6专业SDK上使用nTwitter等库。 预先感谢任何帮助 TomWindows Mobile 6和twitter

回答

0

Twitter可以通过简单的授权Web请求进行控制。为此,您可以使用.NET Framework中的System.Net.HttpWebRequest。下面

的例子演示了如何发布一个状态到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(); 
} 

来源:http://weblogs.asp.net/wallym/archive/2009/03/25/twitter-api-submit-a-post-in-c.aspx

此外,我会建议看看这个页面,准备库:http://dev.twitter.com/pages/libraries#csharp