2012-08-10 2 views
0

나는 데모 webformrtimeline를 경작하려 linqtotiwwter.codeplex.com 에 대한 데모를 따라 beginauthorization위한 푸시 바닥 btnAutorizar 항상 응답이있을 때 그래서 나는 DotNetNuke의 모듈이 코드를 작성 오류 401 Unauthorized. 내 모듈의 설정에 넣은 구성이 있습니다.오류 401하지 Unauhtorized LinqToTiwtter의 API

ConsumerKey : lcgG6BXQpwQtHSzwqWA ConsumerSecret : 6MoV8PlLBktgVaAP5ezDYEHGMKcHGEDe8eDuk5mpas 과 트위터 통화 dnnPrueba

코드 ?? 내 실수는 무엇입니까 내 aplicattion, 내가 무엇을 필요 더? 도와주세요! 그리고 내 영어로 미안해!


public partial class ViewTwitterAndrea : PortalModuleBase {   

private ConfiguracionTwitterAndrea configuracion;  

private WebAuthorizer wbAuthorizer;    

protected void Page_Load(object sender, EventArgs e)  {   

try   {     

configuracion = new ConfiguracionTwitterAndrea(this.TabModuleId);     

string consumerKey = configuracion.ConsumerKey;     

string consumerSecret = configuracion.ConsumerSecret;           

if (string.IsNullOrEmpty(consumerKey) || string.IsNullOrEmpty(consumerSecret))       
{ this.mvTwitterAndrea.SetActiveView(this.vwConfiguracion); } 
else {      
IOAuthCredentials objCredenciales = new SessionStateCredentials();       
if (objCredenciales.ConsumerKey == null || objCredenciales.ConsumerSecret == null)        
{        
objCredenciales.ConsumerKey = configuracion.ConsumerKey;                
objCredenciales.ConsumerSecret = configuracion.ConsumerSecret; 
}     
wbAuthorizer = new WebAuthorizer {         
Credentials=objCredenciales, 
PerformRedirect = authUrl => Response.Redirect(authUrl)  };         
if(!Page.IsPostBack){       
wbAuthorizer.CompleteAuthorization(Request.Url);               
} 
if(string.IsNullOrEmpty(objCredenciales.ConsumerKey) || string.IsNullOrEmpty(objCredenciales.ConsumerSecret)){         
lblRegistrado.Text = "No estas autorizado aun";   
btnAutorizar.Visible = true; 
btnTweets.Visible = false; 
}else if(wbAuthorizer.IsAuthorized){     
lblRegistrado.Text = "Estas Autorizado.";  
btnAutorizar.Visible = false;       
btnTweets.Visible = true;     
}       
this.mvTwitterAndrea.SetActiveView(vwAutorizacion);           
}}catch (Exception ex) {Exceptions.ProcessModuleLoadException(this, ex);  
}  
} 

protected void BtnEnviar_Click(object sender, EventArgs e)  {    
ComunicacionTwitter objTwitter = new ComunicacionTwitter(this.TabModuleId); 
Status objStatus= objTwitter.ActualizarEstado(wbAuthorizer, this.txtEstado.Text); 
} 
protected void btnAutorizar_Click(object sender, EventArgs e) {  
try {    
wbAuthorizer.BeginAuthorization(Request.Url);   
}catch(Exception ex){ }  
} 

protected void btnTweets_Click(object sender, EventArgs e)  {   
try {  
wbAuthorizer = new WebAuthorizer {    
Credentials = new SessionStateCredentials()  }; 
ComunicacionTwitter objTwitter = new ComunicacionTwitter(this.TabModuleId);    
var UltimosTweets = objTwitter.getHomeTimeLine(wbAuthorizer, intCantidadTweets); 
foreach (var Tweet in UltimosTweets)    {     
this.spnTweets.InnerHtml = "<div class='twitterTweet'>" +  
"<div class='twitterUsuario'>Usuario " + Tweet.ScreenName + "</div>" + 
"<div class='twitterContenido'>" + Tweet.Text + "</div>" + 
"<div class='twitterFecha'>" + Tweet.CreatedAt + "</div>" +     
"</div>";    
} 
this.mvTwitterAndrea.SetActiveView(this.vwTweets);    
}catch(Exception ex){ }  
} 
} 
} 

** * ** * ** * * 그리고

Class ConfiguracionTwitter{ 
public ConfiguracionTwitter(){} 
public IEnumerable<Status> getHomeTimeLine(WebAuthorizer auth,int intCantidadTweets) {    
twitterContexto= new TwitterContext(auth);   
var tweets =   
(from tweet in twitterContexto.Status      
where tweet.Type == StatusType.Home       
select tweet).Take(intCantidadTweets).ToList();   
return tweets;   
} 
} 

답변

0

A "(401)는 무단"을 의미 다른 클래스를 가지고 당신의 응용 프로그램이 Twitter로 인증 할 수 없습니다.

http://linqtotwitter.codeplex.com/wikipage?title=LINQ%20to%20Twitter%20FAQ&referringTitle=Documentation

BTW, 당신의 OAuth 키를 게시하는 응용 프로그램이 불안정하게 : 나는 당신에게 확인하는 것들의 목록을 줄 것이다 FAQ를 컴파일 한 (401)을 일으킬 수있는 많은 것들이 있습니다. 가능한 한 빨리 Twitter 페이지에서 앱을 방문하고 새로운 키 세트를 생성해야합니다.

+0

Ok Joe Mayo이 순간 나는 OAuth 키를 변경했습니다 !! –