Aplicación de Windows Forms C # | Enviando Tweet

UPDATE: I still haven't solved it, my my current work around is to not do a desktop client. I've switched back to a web app for now, and everything is working again. I don't know, I'm stumped.

I've been able to get my Twitter web app working just fine, but I've recently decided to add Tweeting functionality from a Windows Form, but I'm having no luck sending tweets. No errors are thrown or anything. Mind looking over my code?

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using TweetSharp;

namespace TwitterAdvirtiser
{
    public partial class Form1 : Form
    {
        private string cKey = "xxx";
        private string cSecret = "xxx";
        private string oToken = "xxx";
        private string aToken = "xxx";



        public Form1()
        {
            InitializeComponent();
            OnStart();
        }

        private void OnStart()
        {
            //Authenticate with Twitter
            TwitterService service = new TwitterService(cKey, cSecret);
            service.AuthenticateWith(oToken, aToken);
            service.SendTweet("testing");
        }
    }
}

It seems like I'm authenticating just fine, I can walk through debug mode and see all my details in the TwitterUser structure, and yet my tweets never show up on my feed. Whats up?

By the way, I'm using Visual Studios 2010, and .NET 4.0. I have verified that the oToken and aToken strings have my developer tokens.

preguntado el 08 de enero de 11 a las 21:01

1 Respuestas

As far as I can see you're only authenticating using the Consumer Key, Consumer Secret, Token Key and Token Secret. You also need to include the verifier pin with the signature base.

Respondido el 09 de enero de 11 a las 00:01

I already have an Access Token and Access Token Secret. I don't need to authenticate multiple users, this is an in-house app that only requires the developer to run it. Shouldn't this work? It works with my web apps. - Andrew Craswell

I haven't built a Twitter using Tweetsharp but I have built my own working Twitter application using my own oauth classes. With most oauth applications I found that once you have the Access Token and Secret, you have all you need to make requests. For Twitter though, for some reason it also requires the 7 digit verifier pin that you used to get the Access Token and Secret. It is usually included in the signature base string as "oauth_verifier=xxxxxxx" - Stephen Dryden

the tokens for making requests are Request tokens if I'm not mistaken (correct me if I'm wrong). When you make a request, you get an access token back. This way you can store the access token an re-authenticate without repeating the entire process. This is what I'm doing here... I think :P - Andrew Craswell

Ver esta goo.gl/aAtOv for the full oauth flow process. You first request a request token and secret. You then authorise the token and secret with a verifier pin. You will then be provided with an access token and access secret which you can use to permanently access Twitter - Stephen Dryden

Alright excellent, Twitter gives the user who registered the application a predesignated access token and secret. Thats what I'm using to authenticate, so I shouldn't need to go through any other authentication. Whats weird is I can go through in debug mode and see the AuthenticateWith() method execute, everything seems fine and the _user field is instantly updated with all my data. So it seem like authentication is working as expected, but SendTweet() does nothing, and returns a TwitterStatus set to null. Thats what confuses me. - Andrew Craswell

No es la respuesta que estás buscando? Examinar otras preguntas etiquetadas or haz tu propia pregunta.