Best backbone APIs


Here are a few of the best APIs to make your website more reliable, powerful, and to save you time we'll even include code samples to get you started FAST!

1. Mandrill - Send/Receive Emails

We used to recommend PostMarkApp, but their customer service was slow, the email verification email wasn't being received, and they don't allow bulk mailing. Mandrill worked perfectly without need for customer service, we emailed them as a test and got a personalized response within a couple hours, and they DO allow bulk mailing! As far as pricing goes, they give you 12,000 free emails each month, and their regular rates aren't bad either! To make life easier, they have a cost calculator.

Example:
function sendEmail($to_email, $to_name, $subject, $message, $from_email, $from_name){
if(empty($to_name) || empty($to_email) || empty($message)){ return false; }
require_once('Mandrill.php');
	try {
    $mandrill = new Mandrill('YOUR_API_KEY');
    $message = array(
        'html' => $message,
        'text' => strip_tags($message),
        'subject' => $subject,
        'from_email' => $from_email,
        'from_name' => $from_name,
        'to' => array(
            array(
                'email' => $to_email,
                'name' => $to_name
            )
        ),
        'headers' => array('Reply-To' => $from_email),
        'important' => false);
    $result = $mandrill->messages->send($message);
    if($result['reject_reason']){ return false; }else{ return true; }
} catch(Mandrill_Error $e) {
    // Mandrill errors are thrown as exceptions
    //echo 'A mandrill error occurred: ' . get_class($e) . ' - ' . $e->getMessage();
    return false;
}
}

2. Rackspace CloudFiles - CDN (Content Delivery Network)

We looked at all the options for our own CDN based on mainly American users, and Rackspace offered the best option in our opinion. Setup was a breeze, price is a lil higher than others, but worth the quality, and speeds are amazing. On the positive side, it's got 4 URLs for http, https, streaming, and streaming on ios (mobile streaming). On the negative, you can't use your own domain for ssl/https, but as long as URL branding/length isn't a huge issue, you should be fine. It's much better to use this then pay $600/mo just to use your own domain with SSL on Amazon's CDN.

Example: (make sure you have php >= 5.3)
require_once('PATH-TO-PHP-API-FILES/lib/php-opencloud.php');
define('AUTHURL', RACKSPACE_US); //leave this
define('USERNAME', 'YOUR_USERNAME');
define('APIKEY', 'YOUR API KEY'); //found by clicking your name after logging in and clicking "api keys"
$connection = new \OpenCloud\Rackspace(AUTHURL,
	array( 'username' => USERNAME,
		   'apiKey' => APIKEY ));
$objstore = $connection->ObjectStore('cloudFiles', 'ORD'); //change ORD to your cdn location (i.e. ORD, DFW, SYD)
/* Already created a container?, select it */
$container = $objstore->Container('NoMoreAgent - Prop Images');
/* Add file to container */
$object = $container->DataObject();
$object->Create(array('name'=>'name-your-file.jpg'), $url-to-file-on-server);
/* Delete file in container */
$object = $container->DataObject();
try{
$object->delete(array('name'=>'name-of-file.jpg'));
}catch(Exception $e){
echo $e;
}

3. Twilio - Send/Receive Calls & SMS

If you're like us, you want to offer the best features to keep current, and this means sending text message notifications, automated calling systems, and more to make communication simple. Twilio allows you to send/receive calls and text messages via a SUPER easy API including their version of XML called TwiML. Their pricing structure is fantastic. Although 1-800 and short numbers cost a bit more, they have a ton of very easy to remember local numbers that work just as well and only cost $1/mo! At that low rate, you can easily afford to get different numbers for each of your applications and keep things simple.

Example:
function sendSMS($to, $message, $convo=false){
  $message = strip_tags($message);
  require_once('twilio-php-master/Services/Twilio.php');
  // Instantiate a new Twilio Rest Client
  $client = new Services_Twilio(YOUR ACCOUNT SID, YOUR AUTH TOKEN);
    $len = strlen($message);
    if($len <= 160){
    $client->account->sms_messages->create(YOUR TWILIO NUMBER, $to, $message);
    }
    else{
	$i = 0;
	while($i<$len){
	$client->account->sms_messages->create(YOUR TWILIO NUMBER, $to, substr($message, $i, 160));
	$i = $i+160;
	}
    }
}




Shane Stebner

Author: Shane Stebner

Shane is a successful web-developer specializing in responsive design, and the open-source LAMP stack. Over the years, he's gained in-depth experience with Stripe, Twilio, PhantomJs, Authorize.net, PayPal, Facebook, Twitter, and many other plugins/APIs.


comments powered by Disqus