Windows Mobile 6 和 Twitter

发布于 2024-09-01 08:26:45 字数 156 浏览 0 评论 0原文

我正在尝试将 Twitter 实现到我正在开发的手机游戏中,但在使用可用的库时遇到困难。有人可以解释一下我如何在 .net Compact Framework 3.5 和 windows mobile 6 professional SDK 上使用 nTwitter 等库 预先感谢您的任何帮助 汤姆

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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

疏忽 2024-09-08 08:26:45

Twitter 可以通过简单的授权网络请求进行控制。为此,您可以使用 .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

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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文