Skip to content

Instantly share code, notes, and snippets.

View jcipriano's full-sized avatar

Jonathan Cipriano jcipriano

View GitHub Profile
@jcipriano
jcipriano / twitter_media_upload.js
Last active March 5, 2016 21:50
Post a Tweet with the Twit Node.js module.
var Twit = require('twit')
var twitter = new Twit({
consumer_key: '',
consumer_secret: '',
access_token: '',
access_token_secret: ''
});
var filePath = 'path/to/video/file'
@jcipriano
jcipriano / twitter_media_upload.py
Created March 5, 2016 21:49
Upload video file with Python TwitterAPI package.
import os
import sys
from TwitterAPI import TwitterAPI
consumer_key = ''
consumer_secret = ''
access_token = ''
access_token_secret = ''
twitter = TwitterAPI(consumer_key, consumer_secret, access_token, access_token_secret)
@jcipriano
jcipriano / twitter-engagement.py
Created April 20, 2016 17:45
Twitter Enagement API Request Example
import requests
import json
from requests_oauthlib import OAuth1
API_URL = 'https://data-api.twitter.com/insights/engagement'
CONSUMER_KEY = 'YOUR_CONSUMER_KEY'
CONSUMER_SECRET = 'YOUR_CONSUMER_SECRET'
ACCESS_TOKEN = 'USER_ACCESS_TOKEN'
ACCESS_TOKEN_SECRET = 'USER_ACCESS_TOKEN_SECRET'
@jcipriano
jcipriano / VideoTweet.py
Created July 6, 2016 22:51
Uploading video with a length of 30 to 140 seconds and file size 15 to 512Mb.
import os
import sys
import time
import json
import requests
from requests_oauthlib import OAuth1
MEDIA_ENDPOINT_URL = 'https://upload.twitter.com/1.1/media/upload.json'
@jcipriano
jcipriano / upload-async.js
Created September 30, 2016 18:59
Twitter Media Upload Async
var request = require('request');
var fs = require('fs');
var MEDIA_ENDPOINT_URL = 'https://upload.twitter.com/1.1/media/upload.json'
var POST_TWEET_URL = 'https://api.twitter.com/1.1/statuses/update.json'
var OAUTH = {
consumer_key: '',
consumer_secret: '',
var nconf = require('nconf')
var request = require('request')
// load config
nconf.file({ file: 'config.json' }).env()
// twitter authentication
var twitter_oauth = {
consumer_key: nconf.get('TWITTER_CONSUMER_KEY'),
@jcipriano
jcipriano / challenge-response.py
Created May 24, 2017 17:15
Creates a valid CRC response for Twitter webhook integration.
import base64
import hmac
import hashlib
import json
# Example app consumer secret found in apps.twitter.com
APP_CONSUMER_SECRET = 'z3ZX4v7mAAUGykl3EcmkqbartmuW8VFOOzCloLx9Q45P0hLrFu'
# Example token provided by incoming GET request
TOKEN = '9b4507b3-9040-4669-9ca3-6b94edb50553'
@jcipriano
jcipriano / challenge-response.js
Created May 24, 2017 17:20
Creates a valid CRC response for Twitter webhook integration.
crypto = require('crypto');
// Example app consumer secret found in apps.twitter.com
APP_CONSUMER_SECRET = 'z3ZX4v7mAAUGykl3EcmkqbartmuW8VFOOzCloLx9Q45P0hLrFu';
// Example token provided by incoming GET request
TOKEN = '9b4507b3-9040-4669-9ca3-6b94edb50553';
/**
@jcipriano
jcipriano / challenge-response.py
Created June 5, 2017 20:57
Python example for generating challenge response for Twitter webhooks
import base64
import hmac
import hashlib
import json
# Example app consumer secret found in apps.twitter.com
APP_CONSUMER_SECRET = 'z3ZX4v7mAAUGykl3EcmkqbartmuW8VFOOzCloLx9Q45P0hLrFu'
# Example token provided by incoming GET request
TOKEN = '9b4507b3-9040-4669-9ca3-6b94edb50553'
@jcipriano
jcipriano / create-welcome-message.js
Last active June 23, 2021 11:54
Creates a Welcome Message and generates a deeplink with NodeJS
var request = require('request')
// twitter authentication
var twitter_oauth = {
consumer_key: 'TWITTER_CONSUMER_KEY',
consumer_secret: 'TWITTER_CONSUMER_SECRET',
token: 'TWITTER_ACCESS_TOKEN',
token_secret: 'TWITTER_ACCESS_TOKEN_SECRET'
}