Git Product home page Git Product logo

sendy-php-api's Introduction

Sendy PHP API Wrapper


Sendy PHP API Wrapper

๐Ÿš€ Sendy PHP API Wrapper: Complete API interfacing.

API Wrapper For Sendy API

With this Sendy PHP API Wrapper you can do the following:

SUBSCRIBERS

  • Subscribe.
  • Unsubscribe.
  • Delete subscriber.
  • Subscription status.

LISTS

  • Active subscriber count.

CAMPAIGNS

  • Create.

Get Started!

Getting started is easy. Here's how you do it. You can check the example.php file as well.

Download โšก๏ธ

Obviously, you'll have to download the wrapper to your current setup. Several ways to do that.

  • Download the library class-sendy-php-api.php curl -O https://git.io/vyFbs

  • Composer Install composer require ahmadawais/sendy-php-api

Step 0. Define SENDY_API.

// Define the global var to avoid direct access to the library class.
define( 'Sendy_PHP_API_Wrapper', TRUE );

Step 1. Require the wrapper.

require_once( 'class-sendy-php-api.php' );

Step 2. Configure it.

$config = array(
    'installation_url' => 'http://send.yourdomain.com',  // Your Sendy installation URL (without trailing slash).
    'api_key'          => 'XXXXXXXXXXXXXXXXXXXXXXXXXX', // Your API key. Aavailable in Sendy Settings.
    'list_id'          => 'XXXXXXXXXXXXXXXXXXXXXXXXXX',
);

Step 3. Init.

$sendy = new \SENDY\Sendy_PHP_API( $config );

API KEY METHODS.

Method #1: Subscribe.

// Method #1: Subscribe.
$result_array = $sendy->subscribe( array(
    'name'   => 'Name',
    'email'  => '[email protected]', // This is the only field required by sendy.
    'custom' => 'field' // You can custom fields as well.
));

Method #2: Unsubscribe.

// Method #2: Unsubscribe.
$result_array = $sendy->unsubscribe( '[email protected]' );

Method #3: Subscriber Status.

// Method #3: Subscriber Status.
$result_array = $sendy->substatus( '[email protected]' );

Method #4: Delete Subscriber.

// Method #4: Delete Subscriber.
$result_array = $sendy->delete( '[email protected]' );

Method #5: Subscriber Count of a list.

// Method #5: Subscriber Count of a list.
$result_array = $sendy->subcount();

Method #6: Campaign โ€” Draft And/Or Send as well.

// Method #6: Campaign โ€” Draft And/Or Send as well.
$result_array = $sendy->campaign( array(
    'from_name'     => 'Your Name',
    'from_email'    => '[email protected]',
    'reply_to'      => '[email protected]',
    'subject'       => 'Your Subject',
    'plain_text'    => 'An Amazing campaign', // (optional).
    'html_text'     => '<h1>Amazing campaign</h1>',
    'brand_id'      => 0, // Required only if you are creating a 'Draft' campaign.
    'send_campaign' => 0 // Set to 1 if you want to send the campaign as well and not just create a draft. Default is 0.
    'list_ids'      => 'your_list_id', // Required only if you set send_campaign to 1.
    'query_string'  => 'some', // Eg. Google Analytics tags.
) );

Method #7: Set List ID.

// Method #7: Change the `list_id` you are referring to at any point.
$sendy->set_list_id( "XXXXXXX" );

Method #8: Get List ID.

// Method #7: Get the `list_id` you are referring to at any point.
$sendy->get_list_id( "XXXXXXX" );

Response

The response of this PHP wrapper is custom built. At the moment, it always returns a PHP Array. This array has the status of your action and an appropriate message in the response.

  • status is either true or false.
  • message is based on the type of action being performed
    // E.g. SUCCESS response.
    array(
        'status'  => true,
        'message' => 'Already Subscribed'
    )
    
    // E.g. FAIL response.
    array(
        'status'  => false,
        'message' => 'Some fields are missing.'
    )

Changelog

Version 1.0.0 2017-03-20

  • First version
  • Basic methods for all API routes.

License & Credits

The code is licensed under MIT and a huge props to Jacob Bennett for his initial work on the lib. Requires at least PHP 5.3.0 (otherwise remove the namespace).

sendy-php-api's People

Watchers

James Cloos avatar Dhiren SHAH 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.