我在 Twitter 上实现共享数据时遇到问题。有没有人有使用 wpf 应用程序共享数据的示例代码?
这是 WPF 中遵循的代码:
在这里,我收到 HttpRequest 错误。
private void button1_Click(object sender, RoutedEventArgs e)
{
var oauth_consumer_key = "XXX";
var oauth_consumer_secret = "YYY";
if(Request["oauth_token"] == null)
{
OAuthTokenResponse reqToken = OAuthUtility.GetRequestToken(
oauth_consumer_key,
oauth_consumer_secret,
Request.Url.AbsoluteUri);
NavigationService nav = NavigationService.GetNavigationService(this);
nav.Navigate(string.Format("http://twitter.com/oauth/authorize?oauth_token={0}", reqToken.Token, UriKind.Relative));
}
else
{
string requestToken = Request["oauth_token"].ToString();
string pin = Request["oauth_verifier"].ToString();
var tokens = OAuthUtility.GetAccessToken(
oauth_consumer_key,
oauth_consumer_secret,
requestToken,
pin);
OAuthTokens accesstoken = new OAuthTokens()
{
AccessToken = tokens.Token,
AccessTokenSecret = tokens.TokenSecret,
ConsumerKey = oauth_consumer_key,
ConsumerSecret = oauth_consumer_secret
};
TwitterResponse<TwitterStatus> response = TwitterStatus.Update(
accesstoken,
"Testing!! It works (hopefully).");
if (response.Result == RequestResult.Success)
{
MessageBox.Show("we did it!");
}
else
{
MessageBox.Show("it's all bad.");
}
}
}