c# - Linq to Twitter status update -


this code

for reason unable update status getting error .

your credentials not allow access resource @

var tweet = twitterctx.updatestatus("hello world");

 var auth = new applicationonlyauthorizer         {             credentials = new inmemorycredentials             {                consumerkey = "",                 consumersecret = ""             }         };          auth.authorize();         //auth.invalidate();         var twitterctx = new twittercontext(auth);         var tweet = twitterctx.updatestatus("hello world"); 

i checked consumerkey , secret correct , gave app read write acccess. able previous status , user name unable tweet new status

application authorization can perform operations application-level. differs other authorizers let operate on behalf of user. logic user has account, application doesn't. therefore, can't tweet on behalf of application because tweet can't assigned anywhere. however, if tweet on behalf of user, tweet goes user's list of statuses (their timeline).

linq twitter has various authorizers , can see them in use downloading samples specific technology you're using. downloadable source code has samples. here's example of how use pin authorizer:

    static itwitterauthorizer dopinoauth()     {         // validate credentials present         if (configurationmanager.appsettings["twitterconsumerkey"].isnullorwhitespace() ||             configurationmanager.appsettings["twitterconsumersecret"].isnullorwhitespace())         {             console.writeline("you need set twitterconsumerkey , twitterconsumersecret in app.config/appsettings. visit http://dev.twitter.com/apps more info.\n");             console.write("press key exit...");             console.readkey();             return null;         }          // configure oauth object         var auth = new pinauthorizer         {             credentials = new inmemorycredentials             {                 consumerkey = configurationmanager.appsettings["twitterconsumerkey"],                 consumersecret = configurationmanager.appsettings["twitterconsumersecret"]             },             authaccesstype = authaccesstype.nochange,             usecompression = true,             gototwitterauthorization = pagelink => process.start(pagelink),             getpin = () =>             {                 // executes after user authorizes, begins call auth.authorize() below.                 console.writeline("\nafter authorizing application, twitter give 7-digit pin number.\n");                 console.write("enter pin number here: ");                 return console.readline();             }         };          // start authorization process (launches twitter authorization page).         auth.authorize();         return auth;     } 

this method returns instance of pinauthorizer, auth, , can use this:

pinauthorizer auth = dopinauth(); var ctx = new twittercontext(auth); ctx.updatestatus("hello linq twitter!"); 

* update *

the preceding code old version of linq twitter. here's example of how newer async version:

    static iauthorizer dopinoauth()     {         var auth = new pinauthorizer()         {             credentialstore = new inmemorycredentialstore             {                 consumerkey = configurationmanager.appsettings["consumerkey"],                 consumersecret = configurationmanager.appsettings["consumersecret"]             },             gototwitterauthorization = pagelink => process.start(pagelink),             getpin = () =>             {                 console.writeline(                     "\nafter authorizing application, twitter " +                     "will give 7-digit pin number.\n");                 console.write("enter pin number here: ");                 return console.readline();             }         };          return auth;     } 

and can use this:

        var auth = dopinoauth();         await auth.authorizeasync();         var twitterctx = new twittercontext(auth);         await twitterctx.tweetasync("hello linq twitter!"); 

for more information, can find documentation , source code. source code has demos in new\demos folder.


Comments

Popular posts from this blog

blackberry 10 - how to add multiple markers on the google map just by url? -

php - guestbook returning database data to flash -

delphi - Dynamic file type icon -