How to use bitly - 10 common examples

To help you get started, we’ve selected a few bitly examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github XinFinOrg / BlockDegree / server / services / shareSocial-cached.js View on Github external
const twit = require("twit");
const ipfsClient = require("ipfs-http-client");
const puppeteer = require("puppeteer");
const fs = require("fs");
const User = require("../models/user");
const axios = require("axios");
const BitlyClient = require("bitly").BitlyClient;
let exec = require("child_process").exec;
const twttr = require("twitter-text");

require("dotenv").config();

// Rate  Limited 1000 calls per hour i.e. {windowMs,max} -> only max requests allowed over windowMs
const bitly = new BitlyClient(process.env.BITLY_ACCESS_TOKEN, {});

let clientIPFS = "";
const xinfinClient = new ipfsClient({
  host: "ipfs.xinfin.network",
  port: 443,
  protocol: "https"
});
const localClient = new ipfsClient("/ip4/127.0.0.1/tcp/5001");
if (process.env.IPFS_NETWORK == "local") {
  clientIPFS = localClient;
} else if (process.env.IPFS_NETWORK == "xinfin") {
  clientIPFS = xinfinClient;
}

exports.postTwitter = async (req, res) => {
  console.log("Called share on twitter by : ", req.user.email);
github firebase / extensions / firestore-shorten-urls-bitly / functions / src / index.ts View on Github external
*/

import * as admin from "firebase-admin";
import * as functions from "firebase-functions";
import { BitlyClient } from "bitly";

import config from "./config";
import * as logs from "./logs";

enum ChangeType {
  CREATE,
  DELETE,
  UPDATE,
}

const bitly = new BitlyClient(config.bitlyAccessToken);
// Initialize the Firebase Admin SDK
admin.initializeApp();

logs.init();

export const fsurlshortener = functions.handler.firestore.document.onWrite(
  async (change): Promise => {
    logs.start();

    if (config.urlFieldName === config.shortUrlFieldName) {
      logs.fieldNamesNotDifferent();
      return;
    }

    const changeType = getChangeType(change);
github XinFinOrg / BlockDegree / server / services / shareSocials.js View on Github external
const twit = require("twit");
const ipfsClient = require("ipfs-http-client");
const puppeteer = require("puppeteer");
const fs = require("fs");
const User = require("../models/user");
const axios = require("axios");
const BitlyClient = require("bitly").BitlyClient;
let exec = require("child_process").exec;
const twttr = require("twitter-text");

require("dotenv").config();

// Rate  Limited 1000 calls per hour i.e. {windowMs,max} -> only max requests allowed over windowMs
const bitly = new BitlyClient(process.env.BITLY_ACCESS_TOKEN, {});

let clientIPFS = "";
const xinfinClient = new ipfsClient({
  host: "ipfs.xinfin.network",
  port: 443,
  protocol: "https"
});
const localClient = new ipfsClient("/ip4/127.0.0.1/tcp/5001");
if (process.env.IPFS_NETWORK == "local") {
  clientIPFS = localClient;
} else if (process.env.IPFS_NETWORK == "xinfin") {
  clientIPFS = xinfinClient;
}

exports.postTwitter = async (req, res) => {
  console.log("Called share on twitter by : ", req.user.email);
github firebase / extensions / rtdb-shorten-urls-bitly / functions / src / index.ts View on Github external
*/

import * as admin from "firebase-admin";
import * as functions from "firebase-functions";
import { BitlyClient } from "bitly";

import config from "./config";
import * as logs from "./logs";

enum ChangeType {
  CREATE,
  DELETE,
  UPDATE,
}

const bitly = new BitlyClient(config.bitlyAccessToken);
// Initialize the Firebase Admin SDK
admin.initializeApp();

logs.init();

export const rtdburlshortener = functions.handler.database.ref.onWrite(
  async (change) => {
    logs.start();

    if (config.urlFieldName === config.shortUrlFieldName) {
      logs.fieldNamesNotDifferent();
      return;
    }

    const changeType = getChangeType(change);
github firebase / extensions / rtdb-shorten-urls-bitly / functions / lib / index.js View on Github external
step((generator = generator.apply(thisArg, _arguments || [])).next());
    });
};
Object.defineProperty(exports, "__esModule", { value: true });
const admin = require("firebase-admin");
const functions = require("firebase-functions");
const bitly_1 = require("bitly");
const config_1 = require("./config");
const logs = require("./logs");
var ChangeType;
(function (ChangeType) {
    ChangeType[ChangeType["CREATE"] = 0] = "CREATE";
    ChangeType[ChangeType["DELETE"] = 1] = "DELETE";
    ChangeType[ChangeType["UPDATE"] = 2] = "UPDATE";
})(ChangeType || (ChangeType = {}));
const bitly = new bitly_1.BitlyClient(config_1.default.bitlyAccessToken);
// Initialize the Firebase Admin SDK
admin.initializeApp();
logs.init();
exports.rtdburlshortener = functions.handler.database.ref.onWrite((change) => __awaiter(this, void 0, void 0, function* () {
    logs.start();
    if (config_1.default.urlFieldName === config_1.default.shortUrlFieldName) {
        logs.fieldNamesNotDifferent();
        return;
    }
    const changeType = getChangeType(change);
    switch (changeType) {
        case ChangeType.CREATE:
            yield handleCreateDocument(change.after);
            break;
        case ChangeType.DELETE:
            handleDeleteDocument();
github xxczaki / bitly-cli-client / cli.js View on Github external
const prompts = require('prompts');
const chalk = require('chalk');
const clipboardy = require('clipboardy');
const normalizeUrl = require('normalize-url');
const isUrl = require('is-url-superb');
const Conf = require('conf');
const firstRun = require('first-run');
const qrcode = require('qrcode-terminal');
const {BitlyClient} = require('bitly');

const config = new Conf();
const adapter = new FileSync('db.json');
const db = low(adapter);

// Bitly Client
const bitly = new BitlyClient(config.get('token'), {});

// Set database defaults
db.defaults({urls: []}).write();

// CLI configuration
const cli = meow(`
	Usage
		$ bitly 
	Options
		--url -u   			Shorten a link
		--qr -q				Generate a QR Code
		--list -l  			List all shortened links
		--purge -p   		Purge the list of saved URLs
		--reset -r          Reset Generic Access Token
	Examples
		$ bitly --url --qr kepinski.me
github resource-watch / resource-watch / components / modal / share-modal / share-modal-actions.js View on Github external
import 'isomorphic-fetch';
import { createAction, createThunkAction } from 'redux-tools';
import { BitlyClient } from 'bitly';

// Actions
export const setShortLinks = createAction('SET_SHARE_SHORT_LINKS');
export const setLoading = createAction('SET_SHARE_SHORT_LINKS_LOADING');
export const setError = createAction('SET_SHARE_SHORT_LINKS_ERROR');
export const resetShortLinks = createAction('RESET_SHARE_SHORT_LINKS');

const BITLY = new BitlyClient(process.env.BITLY_TOKEN);

// Async actions
export const fetchShortUrl = createThunkAction(
  'SHARE_SHORT_URL_FETCH_DATA',
  (payload = {}) => (dispatch) => {
    dispatch(setLoading(true));
    dispatch(setError(null));

    BITLY.shorten(payload.longUrl)
      .then(({ url }) => {
        dispatch(setLoading(false));
        dispatch(setError(null));
        dispatch(setShortLinks({ link: url }));
      })
      .catch((err) => {
        dispatch(setLoading(false));
github firebase / extensions / firestore-shorten-urls-bitly / functions / lib / index.js View on Github external
constructor(urlFieldName, shortUrlFieldName, bitlyAccessToken) {
        super(urlFieldName, shortUrlFieldName);
        this.bitly = new bitly_1.BitlyClient(bitlyAccessToken);
        logs.init();
    }
    shortenUrl(snapshot) {
github nodejitsu / kohai / lib / plugins / twitter.js View on Github external
twitter.start = function (client, config){

  if (!config.auth.bitly.key) {
    console.log("warn: bitly API credentials not detected.  Shortlinks to tweets will not be added.".magenta);
  }
  else {
    twitter.bitly = new Bitly(config.auth.bitly.user, config.auth.bitly.key);
  }
  if ((!config.auth.twitter.access_token_key)&&(!config.auth.twitter.consumer_key)) {
    console.log("warn: twitter credentials not detected, disabling Twitter functionality".magenta);
  } 
  else {
    twit = new twitobj(config.auth.twitter); 
    twit.verifyCredentials(function (data) {
      if (data.statusCode != 200) {
        console.log("err: twitter credentials have been rejected by the Twitter API.".red);
        console.log("Error Status Code".red, data.statusCode);
      }
      else if ((!config.plugins.twitter.userid)||(data.id != config.plugins.twitter.userid)) {
        console.log('info: Twitter has verified new user ID: '.cyan, data.id_str);
        config.plugins.twitter.userid = data.id;
      }
    });
github piotte13 / SIMD-Visualiser / src / components / ButtonPanel.js View on Github external
constructor(props) {
        super(props);
        this.bitly = new BitlyClient('e17981e1eef5e2ec83995b478b899564448b9496', {});

        this.toggleShare = this.toggleShare.bind(this);
        this.state = {
            popoverOpen: false,
            shareLink: 'Loading...'
        };

        this.textAreaRef = React.createRef();
    }

bitly

A Bit.ly API library for Node.JS

MIT
Latest version published 3 years ago

Package Health Score

47 / 100
Full package analysis