-
-
Save ejfox/72144da17b62d07ad32a18b69cd0297f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
T = new Twit( | |
{ | |
consumer_key: '...' | |
consumer_secret: '...' | |
access_token: '...' | |
access_token_secret: '...' | |
timeout_ms: 60*1000 | |
} | |
) | |
uploadTweet = (status, b64Content) -> | |
#console.log 'b64Content', b64Content | |
T.post('media/upload', { media_data: b64Content }, (err, data, response) -> | |
mediaIdStr = data.media_id_string | |
console.log 'Uploading media...' + seed + ' Twitter ID: '+mediaIdStr | |
if !err | |
console.log 'Twitter id:', mediaIdStr | |
altText = 'Randomly generated art from seed: '+seed | |
meta_params = { media_id: mediaIdStr, alt_text: {text: altText} } | |
T.post('media/metadata/create', meta_params, (err, data, response) -> | |
if !err | |
params = { | |
status: status | |
media_ids: [mediaIdStr] | |
} | |
T.post('statuses/update', params, (err, data, response) -> console.log(data)) | |
else | |
console.log 'Error: ', err | |
) | |
else | |
console.log 'Error uploading media: ', err | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment