Windows Phone 7 中的 Twitter 集成

编程入门 行业动态 更新时间:2024-10-27 02:25:23
本文介绍了Windows Phone 7 中的 Twitter 集成的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

限时送ChatGPT账号..

我想从 Twitter 获取用户信息并在 Windows Phone 7 中显示.我找到了一些 Twitter 集成示例.

I want to get the user information from the twitter and show in windows phone 7. I found some examples for twitter integration.

链接 1

链接 2

但在这个例子中,我只能登录到推特.我无法发布或无法获取用户信息.任何人都可以提供 Windows Phone 7 twitter 集成的示例应用程序或链接.

But in this examples i can only login to the twitter. I can not post or can not get the user information. Can any one provide a sample application or links for windows phone 7 twitter integration.

登录后我尝试这样:

 private void btntest_Click(object sender, RoutedEventArgs e)
    {

        string newURL = string.Format("https://api.twitter/1.0/users/show.json?screen_name={0}", userScreenName);

        WebClient webClient = new WebClient();
        webClient.DownloadStringCompleted += new DownloadStringCompletedEventHandler(webBrowser_Navigated);
        webClient.DownloadStringAsync(new Uri(newURL));
    }

    void webBrowser_Navigated(object sender, DownloadStringCompletedEventArgs e)
    {


        if (e.Error != null)
        {
            Console.WriteLine("Error ");
            return;
        }
        Console.WriteLine("Result==> " + e.Result);     
    }

但是在这里我无法获取用户信息.请帮我获取用户信息.

But here i can not get the user information. Please help me to get the user information.

提前致谢.

现在我尝试这样:

public void GetTwitterDetail(string userScreenName)
    {
        var credentials = new OAuthCredentials
          {
              Type = OAuthType.ProtectedResource,
              SignatureMethod = OAuthSignatureMethod.HmacSha1,
              ParameterHandling = OAuthParameterHandling.HttpAuthorizationHeader,
              ConsumerKey = AppSettings.consumerKey,
              ConsumerSecret = AppSettings.consumerKeySecret,
              Token = this.accessToken,
              TokenSecret = this.accessTokenSecret,
              Version = "1.1",
          };

        var restClient = new RestClient
        {
            Authority = "https://api.twitter",
            HasElevatedPermissions = true
        };

        var restRequest = new RestRequest
        {
            Credentials = credentials,
            Path = string.Format("/1.1/users/show.json?screen_name={0}",///1.1/users/show.json?screen_name={0}&include_entities=true
                userScreenName),
            Method = WebMethod.Get
        };
        restClient.BeginRequest(restRequest, new RestCallback(test));
    }

    private void test(RestRequest request, RestResponse response, object obj)
    {
        Deployment.Current.Dispatcher.BeginInvoke(() =>
        {
            Console.WriteLine("Content==> " + response.Content.ToString());
            Console.WriteLine("StatusCode==> " + response.StatusCode);

        });

    }

但我收到此错误:

{"errors":[{"message":"Bad Authentication data","code":215}]}

请帮助我如何解决我的问题?

Please help me how to resolve my problem?

推荐答案

我终于找到了解决方案..!!!:-)

Finally i found the Solution..!!! :-)

public void GetTwitterDetail(string _userScreenName)
    {
        var credentials = new OAuthCredentials
          {
              Type = OAuthType.ProtectedResource,
              SignatureMethod = OAuthSignatureMethod.HmacSha1,
              ParameterHandling = OAuthParameterHandling.HttpAuthorizationHeader,
              ConsumerKey = AppSettings.consumerKey,
              ConsumerSecret = AppSettings.consumerKeySecret,
              Token = this.accessToken,
              TokenSecret = this.accessTokenSecret,
          };

        var restClient = new RestClient
        {
            Authority = "https://api.twitter/1.1",
            HasElevatedPermissions = true
        };

        var restRequest = new RestRequest
        {
            Credentials = credentials,
            Path = string.Format("/users/show.json?screen_name={0}&include_entities=true", _userScreenName),
            Method = WebMethod.Get
        };

        restClient.BeginRequest(restRequest, new RestCallback(test));

    }

    private void test(RestRequest request, RestResponse response, object obj)
    {
        Deployment.Current.Dispatcher.BeginInvoke(() =>
        {
            Console.WriteLine("Content==> " + response.Content.ToString());
            Console.WriteLine("StatusCode==> " + response.StatusCode);
        });
    }

现在我得到了用户的信息..!!!5天的挣扎即将结束..!!谢谢大家..!!

Now i got the User's In formations..!!! 5 days struggling comes to end..!! Thanks to all..!!

这篇关于Windows Phone 7 中的 Twitter 集成的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

更多推荐

[db:关键词]

本文发布于:2023-04-25 14:11:12,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1117653.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:Windows   Phone   Twitter

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!