Code Monkey home page Code Monkey logo

mandrill-php's Introduction

mandrill-php

mandrill-php is a PHP library for interfacing with MailChimp's Mandrill API

##Installation

//Include the Mandrill class
require('Mandrill.php');

##Requirements

##Examples

    // Include Mandrill class
    require('../Mandrill.php');
    
    // The API key can be set in a number of ways, and once it is set it reamins
    // set for subsiquent calls. Here are a few methods of setting the API key.
    Mandrill::setKey('mykey');
    Mandrill::setApiKey('mykey');
    
    // Setting the API key via cosntant
    define('MANDRILL_API_KEY','mykey');
    
    // As a special case, calling setApiKey without an argument sets the api key 
    // in the class to null.
    Mandrill::setApiKey();
    
    // Call Mandrill API's users.info call
    // The docs for this call can be found at http://mandrillapp.com/api/docs/users.html#method=info
    // Also note that the api key can be set and reset with each call request so
    // the following two queries will work.
    Mandrill::call(array('key'=>'mykey', 'type'=>'users', 'call'=>'info'));
    Mandrill::call(array('type'=>'users', 'call'=>'info'));
    
    // The associative array sent is validated against an internal static list of
    // valid Mandrill queries and an exception is raised if an invalid query is specified.
    // For example, the following will produce an error.
    Mandrill::call(array('type'=>'bad_users', 'call'=>'ping'));
    
    // getApiCalls() returns an associative array of valid API queries broken down by
    // call type, ie. users
    Mandrill::getApiCalls();
    
    // For a list of valid calls please visit http://mandrillapp.com/api/docs/index.html
    
    // Setting verbosity to true prints some extra debuggin lines, like the exact 
    // URL and arguments sent to the Mandrill service
    Mandrill::toggleVerbose();
    Mandrill::setVerbose(true);
    
    // getLastError returns the verification error string produced by the last ::call()
    // This is mostly used to produce the verification exception message but it may be
    // useful to you.
    Mandrill::getLastError();

##Contributions

The Mandrill PHP class is 100% static written along a functional or lambda programming paradigm. If you want to learn more about this pattern of development and why this pattern was chosen above other, more traditional, PHP library approaches please read the following excellent blog post http://blog.lcf.name/2011/12/functional-programming-in-php.html

If you would like to help maintain this project and/or if you have any questions or comments about the library's design or implementation I'd love to hear from you.

##Unit Tests

A unit test for the Mandrill class is avaliable in the 'test' directory. You will need to change the Mandrill API key from 'mykey' to your Mandrill API key in order for the tests to complete. If you want to contribute any bugfixes or examples please add a unit test for your code and make sure nothing else breaks.

mandrill-php's People

Contributors

alexey-detr avatar kai5263499 avatar rcoelho avatar tobya avatar

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.