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