lib/twitreq.js
function genReq (options,cb) {

    log(options.verbose,"Starting twitreq ...");

    if ( typeof options.protocol === "undefined" ) {
        options.protocol = PROTOCOL;
    }

    if ( typeof options.host === "undefined" ) {
        options.host = HOST;
    }

    if ( typeof options.oAuthSignatureMethod === "undefined" ) {
        options.oAuthSignatureMethod = OAUTH_SIGNATURE_METHOD;
    }

    if ( options.oAuthSignatureMethod !== OAUTH_SIGNATURE_METHOD ) {
        cb(new Error("HMAC-SHA1 is the only supported signature signing method at present."));
        return;
    }

    if ( typeof options.oAuthVersion === "undefined" ) {
        options.oAuthVersion = OAUTH_VERSION;
    }

    log(options.verbose,"Using options:");
    log(options.verbose,options);

    options.baseURL = options.protocol+"://"+options.host+options.path;
    options.oAuthTimestamp = getTimestamp();

    log(options.verbose,"Generated timestamp: "+options.oAuthTimestamp);

    options.oAuthNonce = getNonce();

    log(options.verbose,"Generated nonce: "+options.oAuthNonce);

    options.oAuthSignature = genOAuthSig(options);
    options.authHeaderValue = genAuthorizationHeaderValue(options);
    options.queryString = genQueryString(options);

    var headers = {};
    headers["Authorization"] = options.authHeaderValue;
    headers["Accept"] = "*/*";
    headers["Connection"] = "close";
    headers["User-Agent"] = "Node.js/twitreq v"+TWITREQ_VERSION;
    headers["Content-Type"] = "application/x-www-form-urlencoded";
    headers["Host"] = options.host;

    var reqOptions = {
        method: options.method,
        path: options.path+options.queryString,
        hostname: options.host,
        headers: headers,
    };

    log(options.verbose,"Complete! Generated request object is:");
    log(options.verbose,reqOptions);

    cb(null,reqOptions);
}
function genReq (options,cb) {

    log(options.verbose,"Starting twitreq ...");

    if ( typeof options.protocol === "undefined" ) {
        options.protocol = PROTOCOL;
    }

    if ( typeof options.host === "undefined" ) {
        options.host = HOST;
    }

    if ( typeof options.oAuthSignatureMethod === "undefined" ) {
        options.oAuthSignatureMethod = OAUTH_SIGNATURE_METHOD;
    }

    if ( options.oAuthSignatureMethod !== OAUTH_SIGNATURE_METHOD ) {
        cb(new Error("HMAC-SHA1 is the only supported signature signing method at present."));
        return;
    }

    if ( typeof options.oAuthVersion === "undefined" ) {
        options.oAuthVersion = OAUTH_VERSION;
    }

    log(options.verbose,"Using options:");
    log(options.verbose,options);

    options.baseURL = options.protocol+"://"+options.host+options.path;
    options.oAuthTimestamp = getTimestamp();

    log(options.verbose,"Generated timestamp: "+options.oAuthTimestamp);

    options.oAuthNonce = getNonce();

    log(options.verbose,"Generated nonce: "+options.oAuthNonce);

    options.oAuthSignature = genOAuthSig(options);
    options.authHeaderValue = genAuthorizationHeaderValue(options);
    options.queryString = genQueryString(options);

    var headers = {};
    headers["Authorization"] = options.authHeaderValue;
    headers["Accept"] = "*/*";
    headers["Connection"] = "close";
    headers["User-Agent"] = "Node.js/twitreq v"+TWITREQ_VERSION;
    headers["Content-Type"] = "application/x-www-form-urlencoded";
    headers["Host"] = options.host;

    var reqOptions = {
        method: options.method,
        path: options.path+options.queryString,
        hostname: options.host,
        headers: headers,
    };

    log(options.verbose,"Complete! Generated request object is:");
    log(options.verbose,reqOptions);

    cb(null,reqOptions);
}
function genReq ( options , cb ) { log ( options . verbose , "Starting twitreq ..." ) ; if ( typeof options . protocol === "undefined" ) { options . protocol = PROTOCOL ; } if ( typeof options . host === "undefined" ) { options . host = HOST ; } if ( typeof options . oAuthSignatureMethod === "undefined" ) { options . oAuthSignatureMethod = OAUTH_SIGNATURE_METHOD ; } if ( options . oAuthSignatureMethod !== OAUTH_SIGNATURE_METHOD ) { cb ( new Error ( "HMAC-SHA1 is the only supported signature signing method at present." ) ) ; return ; } if ( typeof options . oAuthVersion === "undefined" ) { options . oAuthVersion = OAUTH_VERSION ; } log ( options . verbose , "Using options:" ) ; log ( options . verbose , options ) ; options . baseURL = options . protocol + "://" + options . host + options . path ; options . oAuthTimestamp = getTimestamp ( ) ; log ( options . verbose , "Generated timestamp: " + options . oAuthTimestamp ) ; options . oAuthNonce = getNonce ( ) ; log ( options . verbose , "Generated nonce: " + options . oAuthNonce ) ; options . oAuthSignature = genOAuthSig ( options ) ; options . authHeaderValue = genAuthorizationHeaderValue ( options ) ; options . queryString = genQueryString ( options ) ; var headers = { } ; headers [ "Authorization" ] = options . authHeaderValue ; headers [ "Accept" ] = "*/*" ; headers [ "Connection" ] = "close" ; headers [ "User-Agent" ] = "Node.js/twitreq v" + TWITREQ_VERSION ; headers [ "Content-Type" ] = "application/x-www-form-urlencoded" ; headers [ "Host" ] = options . host ; var reqOptions = { method : options . method , path : options . path + options . queryString , hostname : options . host , headers : headers , } ; log ( options . verbose , "Complete! Generated request object is:" ) ; log ( options . verbose , reqOptions ) ; cb ( null , reqOptions ) ; }
Generate a Node HTTP request options object based on a valid set of options.
Generate a Node HTTP request options object based on a valid set of options .