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

No longer works. Must upgrade to Twitter API v.1.1 #110

Open
databasedude opened this issue Jun 12, 2013 · 5 comments
Open

No longer works. Must upgrade to Twitter API v.1.1 #110

databasedude opened this issue Jun 12, 2013 · 5 comments

Comments

@databasedude
Copy link

This was working fine until yesterday around noon when Twitter shut off v.1. It now returns the following error:
"The Twitter REST API v1 will soon stop functioning. Please migrate to API v1.1."

@sebhildebrandt
Copy link

To make "search" working again, I did the following:

in "keys.js", line 8, I corrected the search base to:

search_base: 'https://api.twitter.com/1.1/search', // old was 'http://search.twitter.com'

in "twitter.js", in line 166, I also corrected the search-URL

var url = this.options.search_base + '/tweets.json'; // old was 'search.json';

now it seems to work.

@sebhildebrandt
Copy link

... see updated fork at https://github.com/sebhildebrandt/ntwitter

@SamVerschueren
Copy link

This is my new search function that used the new API.

Twitter.prototype.search = function(q, params, callback) {
    if (typeof params === 'function') {
        callback = params;
        params = {};
     }

    if ( typeof callback !== 'function' ) {
        throw new Error('FAIL: INVALID CALLBACK.');
        return this;
    }

    var url = this.options.rest_base + '/search/tweets.json?q=' + q.replace('#', '%23') + '&' + querystring.stringify(params);

    var request = this.oauth.get(url, this.options.access_token_key, this.options.access_token_secret, function(error, data, response) {
        if ( error && error.statusCode ) {
            var err = new Error('HTTP Error ' + error.statusCode + ': ' + http.STATUS_CODES[error.statusCode]);
            err.statusCode = error.statusCode;
            err.data = error.data;

            callback(err);
        } 
        else if (error) {
            callback(error);
        }
        else {
            try {
                var json = JSON.parse(data);
            } 
            catch(err) {
                return callback(err);
            }

            callback(null, json);
        }
    });

    return this;
}

@technicalpickles
Copy link

@sebhildebrandt could you send out a pull request with those changes?

technicalpickles added a commit to github/hubot-scripts that referenced this issue Jun 18, 2013
After the API retirement, this stopped working. This updates it to use
the ntwitter package, and follows the same configuration conventions as
tweet-mention.coffee for re-use.

It does depend on a fork of ntwitter though, and will need to be so
until AvianFlu/ntwitter#110 is fixed
@j127
Copy link

j127 commented Oct 28, 2013

Doesn't work for me, even when changing lines 8 and 166.

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

5 participants