Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Not tweeting? #3

Closed
oldramen opened this issue May 4, 2012 · 3 comments
Closed

Not tweeting? #3

oldramen opened this issue May 4, 2012 · 3 comments

Comments

@oldramen
Copy link

oldramen commented May 4, 2012

So, following your basic example, I worked this code into an app I've written:

//Twitter
global.mTwitOn                  = true; //Whether or not twitter functions are enabled
global.mTwitTimeout             = 20;       //How often [in minutes] the bot can tweet
global.mTwitKey                 = "xx";     //Consumer Key for Twitter
global.mTwitSecret              = "xx";     //Consumer Secret for Twitter
global.mTwitToken               = "xx-xx";      //Access Token for Twitter
global.mTwitTokenSecret         = "xx";     //Access Secret for Twitter

if (mTwitOn) global.mTwit = require("twit");

if (mTwitKey) {
    Log("Connecting to Twitter");
    global.mTwitter = new mTwit({
        consumer_key:         mTwitKey
      , consumer_secret:      mTwitSecret
      , access_token:         mTwitToken
      , access_token_secret:  mTwitTokenSecret
    });
    global.mLastTweeted = null;
    Log("Done");
}

And this is the function to tweet:

callback: function (pUser, pText) {
        if (!mTwitOn) return;
        var sAge = Date.now() - mLastTweeted;
        var sAge_Minutes = sAge / 60000; 
        if(sAge_Minutes < mTwitTimeout) return Speak(pUser, mTweetSpam, SpeakingLevel.Misc, [['{twitime}', mTwitTimeout]], true);
        if (!pText) {
            if (!mCurrentDJ) return;
            mTwitter.post('statuses/update', {
             status: 'Hello World' 
            }, function(err, reply) {});
            mLastTweeted = Date.now();
            return Speak(pUser, mConfirmTweet, SpeakingLevel.Misc);
        }

Those are all spaced out, I'm only posting the relevant code
All of my code works [my Speak function and whatnot, and I'm not getting any errors, but I'm checking the twitter account I'm connected to, and I'm not getting any tweets showing up.

@ttezel
Copy link
Owner

ttezel commented May 4, 2012

Hi @yayramen,

I read through your code and it looks like it should work. I just cloned twit from github and tried running similar code but I am able to successfully tweet without problems. What are you getting as your err argument in the callback function to mTwitter.post() ? Also, what version of twit are you running?
`

@oldramen
Copy link
Author

oldramen commented May 4, 2012

I'm not sure, I'll throw a console.log(err) in the function to find out. I didn't clone, I used npm install, just seemed simpler.
I'm running 0.1.5 [is what it tells me anyways]. and oath 0.9.7.

Error I got was 'read only cannot post' xD So I'm going to change it to read and write, and try again. I feel so derpy.

Edit: Fixed, closing. Sorry to bug you xD

@oldramen oldramen closed this as completed May 4, 2012
@ttezel
Copy link
Owner

ttezel commented May 5, 2012

great to hear :)

netik pushed a commit to twothinkinc/twit that referenced this issue Jun 3, 2020
Add headers to REST error object
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants