Skip to content

Instantly share code, notes, and snippets.

View wadewegner's full-sized avatar

Wade Wegner wadewegner

View GitHub Profile
namespace ConsoleApplication
{
class Program
{
static void Main(string[] args)
{
var task = RunProgram();
task.Wait();
}
@wadewegner
wadewegner / OnNavigatedTo.cs
Last active August 29, 2015 14:00
Code for blog post on DeveloperForce.WindowsPhone.Login NuGet accelerator
var uri =
Common.FormatAuthUrl(
AuthorizationEndpointUrl,
ResponseTypes.Token,
ConsumerKey,
CallbackUrl,
DisplayTypes.Touch);
WebBrowser.Navigate(new Uri(uri, UriKind.Absolute));
@wadewegner
wadewegner / AccountsPage.cs
Last active August 29, 2015 14:00
Methods supporting the blog post for the Salesforce Accelerator for Windows Store Apps
private async void MainPage_Loaded(object sender, RoutedEventArgs e)
{
await GetAccessToken();
// navigate to AccountsPage.xaml
this.Frame.Navigate(typeof (AccountsPage));
}
@wadewegner
wadewegner / async.py
Created April 30, 2014 17:58
Code used to run the Salesforce Bulk API to perform an UPDATE using Python
import requests
import xml.etree.ElementTree as ET
def login(userName, password):
request = u"""<?xml version="1.0" encoding="utf-8" ?>
<env:Envelope xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:env="http://schemas.xmlsoap.org/soap/envelope/">
<env:Body>
@wadewegner
wadewegner / addBatch.py
Last active June 29, 2020 20:55
Source code for blog post on using the bulk API with Python
def addBatch(instance, sessionId, jobId, objects):
request = u"""<?xml version="1.0" encoding="UTF-8"?>
<sObjects xmlns="http://www.force.com/2009/06/asyncapi/dataload">
""" + objects + """
</sObjects>"""
encoded_request = request.encode('utf-8')
url = "https://" + instance + ".salesforce.com/services/async/30.0/job/" + jobId + "/batch"
@wadewegner
wadewegner / upload_rest.py
Last active August 9, 2024 16:01
Upload attachment to Salesforce using Python
import requests
import base64
import json
from simple_salesforce import Salesforce
userName = ''
password = ''
securityToken = ''
instance = ''
import os
import psycopg2
import urlparse
urlparse.uses_netloc.append("postgres")
url = urlparse.urlparse(os.environ["DATABASE_URL"])
conn = psycopg2.connect(
database=url.path[1:],
user=url.username,
import os
import psycopg2
import urlparse
import pika, logging
urlparse.uses_netloc.append("postgres")
url = urlparse.urlparse(os.environ["DATABASE_URL"])
logging.basicConfig()
@wadewegner
wadewegner / TokenValidationHandler.cs
Last active August 29, 2015 14:05
TokenValidationHandler
public class TokenValidationHandler : DelegatingHandler
{
private readonly string _storageConnectionString = CloudConfigurationManager.GetSetting("StorageConnectionString");
protected override async Task<HttpResponseMessage> SendAsync(HttpRequestMessage request, CancellationToken cancellationToken)
{
const string errorMessage = "Unauthorized access; {0}";
const HttpStatusCode code = HttpStatusCode.Unauthorized;
var authValue = request.Headers.Authorization;
<?xml version="1.0" encoding="utf-16"?>
<application xmlns="http://wadl.dev.java.net/2009/02" xmlns:siena="http://schemas.microsoft.com/MicrosoftProjectSiena/WADL/2014/11" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:sienatool="http://www.todo.com"
siena:serviceId="WadeAPIServiceWadl">
<grammars>
<jsonTypes targetNamespace="http://www.todo.com" xmlns="http://schemas.microsoft.com/MicrosoftProjectSiena/WADL/2014/11">
<object name="GetAccounts_Root">
<property name="totalSize" type="number" />
<property name="done" type="boolean" />
<property name="records" typeRef="GetAccounts_records_Array" />
</object>