내 영어에 대해 불쌍하지만 당신을 도울 것입니다!
먼저 자신의 트위터 카운트의 사용자와 비밀번호로 인증을 생성해야합니다. 당신은 당신의 이름에 놓여져 aplicattion을 등록 여기이 페이지 http://dev.twitter.com에 트위터에 aplication을 등록해야하는 또 다른 방법이있다
UsernamePasswordAuthorization cxauthentication = new UsernamePasswordAuthorization();
ctxauthenticatin.UserName = userName; // Put in your Twitter Account
ctxauthenticatin.Password = password; // and password
ctxauthenticatin.AllowUIPrompt = false;
ctxauthenticatin.SignOn();
var ctxTwitterContext = new TwitterContext(ctxauthentication);
ctxTwitterContext.UpdateStatus("test text");
, 웹의 direccion은, 그들은 당신에게 ConsumerKey, ConsumerSecert을주고 액세스 토큰을 생성하는 경우에는 AccessToken 및 AccessTokenSecret을 제공합니다. Remenber 설정으로 이동하여 직접 메시지 읽기, 쓰기 및 액세스 옵션을 선택합니다. 그런 다음 AccessToken을 생성하십시오. 코드에서이 가진 좋아 당신은 이런 식으로 뭔가를 할 :
public partial class _Default : System.Web.UI.Page
{
private WebAuthorizer auth;
private TwitterContext twitterCtx;
protected void Page_Load(object sender, EventArgs e)
{
IOAuthCredentials credentials = new SessionStateCredentials();
if (credentials.ConsumerKey == null || credentials.ConsumerSecret == null)
{
credentials.ConsumerKey = "Here put your ConsumerKey";
credentials.ConsumerSecret = "Here put your ConsumerSecret"
}
auth = new WebAuthorizer
{
Credentials = credentials,
PerformRedirect = authUrl => Response.Redirect(authUrl)
};
if (!Page.IsPostBack)
{
auth.CompleteAuthorization(Request.Url);
}
twitterCtx = new TwitterContext(auth);
}
protected void authorizeTwitterButton_Click(object sender, EventArgs e)
{
auth.BeginAuthorization(Request.Url);
}
보호 무효 SendTweet_Click (개체 보낸 사람, EventArgs입니다 전자) { twitterCtx.UpdateStatus ("내 테스트 트윗");
}
Easy !! 좋아, 어떻게 작동하는지! 먼저 authorizeTwitterButton 버튼을 클릭하면 트위터 계정에 대한 권한 부여가 시작되고 응용 프로그램에 권한을 부여한 트위터에 로그인 한 다음 새 윈도우가 열리고 트위터가 자격 증명이있는 페이지로 리디렉션되므로 보내기 버튼을 클릭하면 당신은 새로운 트윗을 게시합니다!
시작 및 완료 인증 방법을 사용하지 않아도되는 또 다른 방법이 있습니다. 여기서 모든 자격 증명을 직접 소개합니다. 예 :
var auth = new SingleUserAuthorizer
{
Credentials = new InMemoryCredentials
{
ConsumerKey = "your ConsumerKey",
ConsumerSecret = "Your consumerSecret",
OAuthToken = "your AccessToken",
AccessToken = "your AccessTokenSecret"]
}
};
var ctxTwitterContext = new TwitterContext(auth);
ctxTwitterContext.UpdateStatus("test text");
Ok! 내 anwser 도움이되기를 바랍니다 !! 자세한 내용은 http://linqtotwitter.codeplex.com/ 의 설명서를 참조하십시오. 당신이 내 anwser을 좋아한다면 그냥 클릭하십시오! jaja
많은 고통과 다양한 .NET 트위터 래퍼 후에 나는 nuget 패키지 관리자 인 http://visualstudiogallery.msdn.microsoft.com/27077b70-9dad-4c64-adcf-c7cf6bc9970c를 가져 와서 거기에서 tweetsharp를 설치했습니다. –
Linq-to-twitter? 코드에는 140 자만 허용됩니까? 대신 TwitterContext (UsernamePasswordAuthorization) 생성자를 사용해보십시오. –
@HansPassant : 그것에 관한 문서가 없습니다. 그러나 나는 tweetsharp와 mono/linux로 작업하고있다. –