. , IConsumerTokenManager. , , ConsumerKey, ConsumerSecret GetTokenSecret ( ).
#region Namespaces
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using DotNetOpenAuth.OAuth.ChannelElements;
using DotNetOpenAuth.OAuth.Messages;
#endregion
namespace BingMapTest
{
public class ConsumerTokenManager : IConsumerTokenManager
{
public string ConsumerKey
{
get { return "xxxxxxxx"; }
}
public string ConsumerSecret
{
get { return "xxxxxxxx"; }
}
public string GetTokenSecret(string token)
{
return "xxxxxxxx";
}
public void ExpireRequestTokenAndStoreNewAccessToken(string consumerKey, string requestToken, string accessToken, string accessTokenSecret)
{
throw new NotImplementedException();
}
public TokenType GetTokenType(string token)
{
throw new NotImplementedException();
}
public bool IsRequestTokenAuthorized(string requestToken)
{
throw new NotImplementedException();
}
public void StoreNewRequestToken(UnauthorizedTokenRequest request, ITokenSecretContainingMessage response)
{
throw new NotImplementedException();
}
}
}
, Page_Load ConsumerTokenManager:
protected void Page_Load(object sender, EventArgs e)
{
ITwitterAuthorization auth;
ConsumerTokenManager tokenManager = new ConsumerTokenManager();
auth = new WebOAuthAuthorization(tokenManager, "accessToken");
auth.UseCompression = true;
using (var twitterCtx = new TwitterContext(auth, "https://api.twitter.com/1/", "https://search.twitter.com/"))
{
try
{
auth.SignOn();
}
catch (OperationCanceledException)
{
return;
}
}
}
, , - .