I Suivez la démo pour linqtotiwwter.codeplex.com J'ai essayé de la jachère webformrtimeline de démonstration j'ai donc écrit ce code pour un module DotNetNuke quand une poussée au fond btnAutorizar pour beginauthorization toujours la réponse est Erreur 401 non autorisée. il y a la configuration que je mets dans les paramètres de mon module.Erreur 401 Non Unauhtorized API LinqToTiwtter
ConsumerKey: lcgG6BXQpwQtHSzwqWA ConsumerSecret: 6MoV8PlLBktgVaAP5ezDYEHGMKcHGEDe8eDuk5mpas et mon aplicattion sur Twitter dnnPrueba appel
Quelle est mon erreur dans le code ??, quoi de plus je besoin? Aidez-moi, s'il vous plaît! et désolé pour mon anglais!
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){ }
}
}
}
** * ** * ** * * Et j'ai une autre classe
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;
}
}
Ok Joe Mayo En ce moment, je suis changin les clés OAuth !! –