Skip to content

Instantly share code, notes, and snippets.

Avatar

Pat Patterson metadaddy

View GitHub Profile
@metadaddy
metadaddy / GeocodingUtil.cls
Created September 22, 2011 23:04
Parse a Google Maps response from a String
View GeocodingUtil.cls
public class GeocodingUtil {
//@future(callout=true)
public static void callGoogleGeocodingService() {
/*
Http httpProtocol = new Http();
// Create HTTP request to send.
HttpRequest request = new HttpRequest();
// Set the endpoint URL.
@metadaddy
metadaddy / MetadataSample.java
Created November 2, 2011 16:01
Set login IP ranges via the Metadata API
View MetadataSample.java
package com.force.samples;
import com.sforce.soap.enterprise.Connector;
import com.sforce.soap.enterprise.EnterpriseConnection;
import com.sforce.soap.metadata.AsyncRequestState;
import com.sforce.soap.metadata.AsyncResult;
import com.sforce.soap.metadata.MetadataConnection;
import com.sforce.soap.metadata.Profile;
import com.sforce.soap.metadata.ProfileLoginIpRange;
import com.sforce.soap.metadata.UpdateMetadata;
@metadaddy
metadaddy / metadata.php
Created November 7, 2011 22:24
PHP Classes Generated from Force.com Metadata API WSDL
View metadata.php
<?php
// Avoid clashes with classes defined in SforceHeaderOptions.php
namespace metadata;
// PHP classes corresponding to the data types in defined in WSDL
class checkDeployStatus {
/**
* @var string
@metadaddy
metadaddy / restquery.py
Created November 17, 2011 22:29
Simple query against Force.com REST API in Python
View restquery.py
import os
import urllib
import urllib2
import json
import pprint
# Grab credentials from the environment
consumer_key = os.environ['CLIENT_ID']
consumer_secret = os.environ['CLIENT_SECRET']
username = os.environ['USERNAME']
@metadaddy
metadaddy / soapdebug.php
Created February 27, 2012 19:06
How to see raw SOAP request/response in Force.com Toolkit for PHP (https://github.com/developerforce/Force.com-Toolkit-for-PHP)
View soapdebug.php
<?php
require_once ('soapclient/SforcePartnerClient.php');
define("SF_SECURITY_TOKEN", getenv("SECURITY_TOKEN"));
define("SF_USERNAME", getenv("USERNAME"));
define("SF_PASSWORD", getenv("PASSWORD"));
$mySforceConnection = new SforcePartnerClient();
$mySforceConnection->createConnection("soapclient/partner.wsdl.xml");
$response = $mySforceConnection->login(SF_USERNAME, SF_PASSWORD.SF_SECURITY_TOKEN);
@metadaddy
metadaddy / SmsToLead.cls
Created April 24, 2012 18:31
SMS-to-Lead
View SmsToLead.cls
/*
* SmsToLead.cls
*
* Shows how to receive SMS messages in Apex Code, creating Leads in a Campaign
*/
@RestResource(urlMapping='/smstolead')
global class SmsToLead {
static TwilioAccount account = TwilioAPI.getDefaultAccount();
@future(callout=true)
@metadaddy
metadaddy / portalauth.php
Created May 24, 2012 21:40
Calling Force.com SOAP API on behalf of a portal user
View portalauth.php
<?php
require_once ('soapclient/SforcePartnerClient.php');
function get_resource($url, $access_token) {
$curl = curl_init($url);
curl_setopt($curl, CURLOPT_HEADER, false);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_HTTPHEADER,
array("Authorization: OAuth $access_token"));
curl_setopt($curl, CURLOPT_FOLLOWLOCATION, true);
@metadaddy
metadaddy / Friends.page
Created June 29, 2012 15:32
Expanding Facebook Scope from a Force.com Social Application
View Friends.page
<apex:page controller="FriendsController">
<script src="https://connect.facebook.net/en_US/all.js"></script>
<div id="fb-root"></div>
<script>
// Get required permissions from the controller
var permissions = '{!permissions}';
var permlist = permissions.split(',');
var reqperms = '';
FB.init({appId: '{!appId}', xfbml: true, cookie: true});
@metadaddy
metadaddy / Hello.page
Created July 23, 2012 16:50
Post to Facebook stream from Apex controller
View Hello.page
<apex:page controller="HelloController">
<script src="https://connect.facebook.net/en_US/all.js"></script>
<div id="fb-root"></div>
<script>
// Get required permissions from the controller
var permissions = '{!permissions}';
var permlist = permissions.split(',');
var reqperms = '';
FB.init({appId: '{!appId}', xfbml: true, cookie: true});
@metadaddy
metadaddy / server.c
Created July 23, 2012 18:08 — forked from anonymous/server.c
sendfile
View server.c
/* receive e-mail */
void receive_mail(char *filename, int sock_fd)
{
/* file descriptor for destination file */
int destination_fd;
/* byte offset used by sendfile */
off_t offset = 0;