问题描述
限时送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:关键词]
发布评论