Skip to content

Instantly share code, notes, and snippets.

View thinkingserious's full-sized avatar

Elmer Thomas thinkingserious

View GitHub Profile
@thinkingserious
thinkingserious / HomeController.cs
Created July 18, 2014 00:43
SendGrid Event Webhook Client Endpoint
using System.Collections.Generic;
using System.Web;
using System.Web.Mvc;
using SendGridEventWebhook.Models;
using Newtonsoft.Json;
namespace SendGridEventWebhook.Controllers
{
// Display the default home page for this example
public class HomeController : Controller
@thinkingserious
thinkingserious / GetStats-WindowsPhone-SendGrid.cs
Last active August 29, 2015 14:05
GetStats - a function that retrieves data from the SendGrid Web API stats endpoint from within a Windows Phone 8.1 app
public async Task<ObservableCollection<EmailStats>> GetStats(uint days = 1, uint aggregate = 0)
{
if (days < 1)
throw new ArgumentException("The days argument must be larger than 0.", "days");
if (days > 1095)
throw new ArgumentException("The days argument must be less than 1096.", "days");
var httpClient = new HttpClient();
var response = await httpClient.GetAsync(
new Uri(String.Format("{0}stats.get.json?api_user={1}&api_key={2}&date=1&days={3}&aggregate={4}",

Keybase proof

I hereby claim:

  • I am thinkingserious on github.
  • I am thinkingserious (https://keybase.io/thinkingserious) on keybase.
  • I have a public key whose fingerprint is 64E5 2C12 D835 AEB8 A109 DFA2 990F 4A17 FDBF EDC1

To claim this, I am signing this object:

@thinkingserious
thinkingserious / sendgrid_python_api_keys_example.py
Last active September 22, 2015 15:57
SendGrid Python v3 API Keys Example
import sendgrid
import os
if os.path.exists('.env'):
for line in open('.env'):
var = line.strip().split('=')
if len(var) == 2:
os.environ[var[0]] = var[1]
client = sendgrid.SendGridAPIClient(os.environ.get('SENDGRID_API_KEY'))
status, msg = client.apikeys.get()
@thinkingserious
thinkingserious / sendgrid_python_asm_groups_example.py
Last active September 23, 2015 16:55
SendGrid Python v3 ASM Groups Example
import sendgrid
import os
if os.path.exists('.env'):
for line in open('.env'):
var = line.strip().split('=')
if len(var) == 2:
os.environ[var[0]] = var[1]
client = sendgrid.SendGridAPIClient(os.environ.get('SENDGRID_API_KEY'))
status, msg = client.asm_groups.get()
@thinkingserious
thinkingserious / sendgrid_python_asm_suppressions_example.py
Last active September 23, 2015 23:42
SendGrid Python v3 ASM Suppressions Example
import sendgrid
import os
if os.path.exists('.env'):
for line in open('.env'):
var = line.strip().split('=')
if len(var) == 2:
os.environ[var[0]] = var[1]
# POST
@thinkingserious
thinkingserious / sendgrid-csharp-test.cs
Created September 29, 2015 18:07
SendGrid CSharp Test
var myMessage = new SendGridMessage();
myMessage.From = new MailAddress("elmer@thinkingserious.com");
myMessage.AddTo("elmer.thomas@sendgrid.com");
myMessage.Subject = "Testing the SendGrid Library";
myMessage.Text = "Hello World";
var sg_username = Environment.GetEnvironmentVariable("SENDGRID_USERNAME");
var sg_password = Environment.GetEnvironmentVariable("SENDGRID_PASSWORD");
var credentials = new NetworkCredential(sg_username, sg_password);
var transportWeb = new Web(credentials);
transportWeb.DeliverAsync(myMessage);
@thinkingserious
thinkingserious / sendgrid_php_api_keys_example.php
Created October 13, 2015 16:45
SendGrid PHP v3 API Keys Example
<?php
require 'vendor/autoload.php';
require 'lib/SendGrid.php';
require 'lib/Client.php';
Dotenv::load(__DIR__);
$sendgrid_apikey = getenv('SG_KEY');
$sendgrid = new Client($sendgrid_apikey);
$response = $sendgrid->api_keys->get();
@thinkingserious
thinkingserious / sendgrid_python_asm_global_suppressions_example.py
Created October 14, 2015 16:12
SendGrid Python v3 ASM Global Suppressions Example
import sendgrid
import json
import os
if os.path.exists('.env'):
for line in open('.env'):
var = line.strip().split('=')
if len(var) == 2:
os.environ[var[0]] = var[1]
@thinkingserious
thinkingserious / sendgrid_python_asm_groups_post_example.py
Created October 15, 2015 23:34
SendGrid Python v3 ASM Groups Example [POST]
import sendgrid
import os
if os.path.exists('.env'):
for line in open('.env'):
var = line.strip().split('=')
if len(var) == 2:
os.environ[var[0]] = var[1]
client = sendgrid.SendGridAPIClient(os.environ.get('SENDGRID_API_KEY'))
status, msg = client.asm_groups.post("Magic Key", "Unlock your Emails")