Skip to content

Instantly share code, notes, and snippets.

Avatar

Kevin Whinnery kwhinnery

  • Twilio
  • Saint Paul / Minneapolis
View GitHub Profile
View sync.js
var map = client.sync.map('uniqueName');
map.set('foo', { bar: 42 }).then(function() {
console.log('set it!');
}).catch(function(err) {
console.log('dang it, dont have access');
});
// same as above...
map.set('foo', { bar: 42 }, function(err) {
View conversation.js
var channel = client.channel('uniqueName');
channel.listMessages().then(function(messages) {
console.log(messages);
}).catch(function(err) {
console.log('whoops! I dont have access to this channel');
});
View demo.js
var client = twilio.sync('jwt token here');
// Example Document interaction
var doc = client.Document('uniqueName');
doc.set({
foo: 'bar'
});
doc.on('update', function(e) {
View demo.js
var client = require('twilio')('sid', 'token');
var pager = client.messages.each({ pageSize: 100 });
pager.on('data', function(message) {
console.log(message.sid);
});
pager.on('end', function() {
console.log('no more messages!');
View test.js
var Twilio = require('./index').Twilio;
var c = new Twilio();
c.api.messages.create({
to: '+16512080532',
from: process.env.TWILIO_NUMBER,
body: 'hey there'
}).then(function(data) {
console.log(data);
View right.js
Property.findOne({
_id: propertyId
}).then(function (property) {
var reservation = new Reservation({
message: req.body.message,
property: propertyId,
guest: user.id
});
return reservation.save();
View right.js
var mongoose = require('mongoose');
var propertySchema = new mongoose.Schema({
description: { type: String, required: true },
imageUrl: { type: String, required: true },
date: { type: Date, default: Date.now },
owner: {
type: mongoose.Schema.Types.ObjectId,
ref: 'user'
}
View example.css
@import url(https://fonts.googleapis.com/css?family=Share+Tech+Mono);
body,
p {
padding: 0;
margin: 0
}
body {
background: #272726
}
View app.js
var accountSid = 'ACCOUNT_SID';
var authToken = 'AUTH_TOKEN';
var IpMessagingClient = require('twilio').IpMessagingClient
var client = new IpMessagingClient(accountSid, authToken);
var service = client.services('SERVICE_SID');
service.channels.list().then(function(response) {
console.log(response);
}).fail(function(error) {
@kwhinnery
kwhinnery / App.java
Created Nov 24, 2015
How to test SSL cert changes on api.twilio.com:8443
View App.java
// You may want to be more specific in your imports
import java.util.*;
import com.twilio.sdk.*;
import com.twilio.sdk.resource.factory.*;
import com.twilio.sdk.resource.instance.*;
import com.twilio.sdk.resource.list.*;
public class App {
// Find your Account Sid and Token at twilio.com/user/account
public static final String ACCOUNT_SID = "AC5ef872f6da5a21de157d80997a64bd33";