Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

send-php-api

ahmadawais22MIT6.0.0

Sendy PHP API Wrapper: Complete API interfacing

Sendy-PHP-API, Ahmad Awais, ahmadawais

readme

🚀 Sendy PHP API Wrapper: Complete API interfacing.

emoji-log

📨 SENDY API

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

SUBSCRIBERS LISTS CAMPAIGNS
Subscribe Set List Create
Unsubscribe Get List Draft
Delete subscriber Active subscriber count Send
Subscription status List Segments handling Assign to brands

Getting Started

Getting started is easy. Here's how you do it. You can check the example.php file as well. Obviously, you'll have to download the wrapper to your current setup. Several ways to do that.

#1 MANUAL INSTALL:

Git clone this repo and include ./src/Sendy.php in your project.

#2 COMPOSER INSTALL:

Composer Install is the preferred method.

composer require ahmadawais/sendy-php-api

Step 0. Require the wrapper

// New way using PSR4 Standard autoloader. Recommended
require_once . '/vendor/autoload.php';

// Old way of requiring all files manually. Not recommended.
require_once( 'API.php' );

Step 1. Configure it

// 2. Configuration.
$config = [
    'sendyUrl' => 'https://send_installation_url.com', // Your Sendy installation URL (without trailing slash).
    'apiKey'   => 'XXXXXXXXXXXXXXXX', // Your API key. Available in Sendy Settings.
    'listId'   => 'XXXXXXXXXXXXXXXX',
];

Step 2. Init

use AhmadAwais\Sendy\API as Sendy;

$sendy = new Sendy( $config );

API KEY METHODS

  1. Method: subscribe().
  2. Method: unsubscribe().
  3. Method: subStatus().
  4. Method: delete().
  5. Method: subCount().
  6. Method: campaign().

Method #1: Subscribe

// Method #1: Subscribe.
$responseArray = $sendy->subscribe(
    [
        'email'     => 'your@email.com', // This is the only field required by sendy.
        'name'      => 'Name', // User name (optional).
        'custom'    => 'Field Value', // You can custom fields as well (optional).
        'country'   => 'US', // User 2 letter country code (optional).
        'ipaddress' => 'XX.XX.XX.XXX', // User IP address (optional).
        'referrer'  => 'https://AhmadAwais.com/', // URL where the user signed up from (optional).
        'gdpr'      => true, // GDPR compliant? Set this to "true" (optional).
    ]
);

Method #2: Unsubscribe

$responseArray = $sendy->unsubscribe( 'your@email.com' );

Method #3: Subscriber Status

$responseArray = $sendy->subStatus( 'your@email.com' );

Method #4: Delete Subscriber

$responseArray = $sendy->delete( 'your@email.com' );

Method #5: Subscriber Count of a list

$responseArray = $sendy->subCount();

Method #6: Campaign — Draft And/Or Send as well

// Method #6: Campaign — Draft And/Or Send as well.
$responseArray = $sendy->campaign(
    array(
        'from_name'            => 'Your Name',
        'from_email'           => 'your@email.com',
        'reply_to'             => 'your@email.com',
        'title'                => 'Title', // the title of your campaign.
        'subject'              => 'Your Subject',
        'plain_text'           => 'An Amazing campaign', // Optional.
        'html_text'            => '<h1>Amazing campaign</h1>',
        'brand_id'             => 1, // Required only if you are creating a 'Draft' campaign. That is `send_campaign` set to 0.
        'send_campaign'        => 0, // SET: Draft = 0 and Send = 1 for the campaign.
        // Required only if you set send_campaign to 1 and no `segment_ids` are passed in.. List IDs should be single or comma-separated.
        'list_ids'             => 'XXXXXXXX, XXXXXXXX',
        // Required only if you set send_campaign to 1 and no `list_ids` are passed in. Segment IDs should be single or comma-separated.
        'segment_ids'          => '1',
        // Lists to exclude. List IDs should be single or comma-separated. (optional).
        'exclude_list_ids'     => '',
        // Segments to exclude. Segment IDs should be single or comma-separated. (optional).
        'exclude_segments_ids' => '',
        'query_string'         => 'XXXXXXXX', // Eg. Google Analytics tags.
    )
);

Method #7: Set List ID

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

Method #8: Get List ID

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

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.
    [
        'status'  => true,
        'message' => 'Already Subscribed'
    ];

    // E.g. FAIL response.
    [
        'status'  => false,
        'message' => 'Some fields are missing.'
    ];

📝

Changelog

❯ Read the changelog here →


KEY: 📦 NEW, 👌 IMPROVE, 🐛 FIX, 📖 DOC, 🚀 RELEASE, and ✅ TEST

I use Emoji-log, you should try it and simplify your git commits.


📃

License & Conduct

  • MIT © Ahmad Awais
  • Code of Conduct
  • Props to Jacob Bennett for his initial work on the lib.
  • Requires at least PHP 5.3.0 (otherwise remove the namespaces).

🙌

Connect

GitHub @AhmadAwais (follow) To stay up to date on free & open-source software

Twitter @MrAhmadAwais (follow) To get #OneDevMinute daily hot tips & trolls

YouTube AhmadAwais (subscribe) To tech talks & #OneDevMinute videos

Blog: AhmadAwais.com (read) In-depth & long form technical articles

LinkedIn @MrAhmadAwais (connect) On the LinkedIn profile y'all


👌

Me (Ahmad Awais) and my incredible wife (Maedah Batool) are two engineers who fell in love with open source and then with each other. You can read more about me here. If you or your company use any of my projects or like what I’m doing then consider backing me. I'm in this for the long run. An open-source developer advocate.

Ahmad on Twitter

Ahmad on Twitter

changelog

CHANGELOG

All notable changes in this project's released versions are documented in this file.

Support my work: If you or your company use any of my projects or like what I’m doing then consider backing me. I'm in this for the long run. An open-source developer advocate.

Sponsor Awais Node.js CLI Automation VSCode Follow @MrAhmadAwais on Twitter


I have released a video course to help you build Node.js CLIs for Automation


NodeCLI.com


hr

CHANGELOG KEY: 📦 NEW, 👌 IMPROVE, 🐛 FIX, 📖 DOC, 🚀 RELEASE, 🤖 TEST, and ‼️ BREAKING.

I use Emoji-log, you should try it and simplify your git commits.


hr


RELEASE: v6.0.0

BREAKING

‼️ Namespace + PSR4 Compat Upgrade 7e9eacb


hr


RELEASE: 5.4.0

🐛 FIX:

🐛 5.4 4458dc8

📖 DOC:

📖 Changelog 414a75d


hr


RELEASE: 5.3.0

📦 NEW:

📦 5.3 f9545cd

📖 DOC:

📖 Changelog d91c69b


hr


RELEASE: 5.2.0

BREAKING

‼️ PSR4 Compat Class File Name changed to API.php f593275

🐛 FIX:

🐛 Ex b3d795a
🐛 Composer ceeb8f9

📖 DOC:

📖 Changelog 16637e7
📖 Changelog f99a2dc


hr


RELEASE: 5.0.0

BREAKING

‼️ PSR4 Compat Class File Name changed to API.php 2babf74

📦 NEW:

📦 Extraneous npm files 33e5d99
📦 TheDevCouple Open Source Sponsors 89ea231
📦 API Key for all calls 7a89813
📦 SSL Verification de82794
📦 5.0.0 ddcc421
📦 Year ca662f9

👌 IMPROVE:

👌 PSR4 Compat 2d85e82
👌 CoC 620baac
👌 Docs 8d9e2dd
👌 Lower-case names 5e769b8

🐛 FIX:

🐛 Release data. fa2fa48
🐛 Release data. ead53ce

📖 DOC:

📖 Changelog 2be5dae
📖 Updates e2e9de4
📖 Sponsor 8f19560
📖 Changelog 7371ba7
📖 Changelog 7e14df3
📖 Improved lingo 60e6f5e
📖 Changelog b45ba23


hr


RELEASE: 2.4.0

📦 NEW:

📦 npm updates pakcages 2f0b159

🐛 FIX:

🐛 Link 0e079ae


hr


RELEASE: 2.3.0

👌 IMPROVE:

👌 versions 08a03d9

🐛 FIX:

🐛 name 920e2f7


hr


RELEASE: v2.2.0


hr


RELEASE: 2.2.0

📦 NEW:

📦 Sendy Class Lib 1f9fc1e
📦 composer-version 7c7a5b2


hr


RELEASE: 2.1.0

📦 NEW:

📦 Glob bug fix f5c8da9

🐛 FIX:

🐛 Ignore glob 5c2534f

📖 DOC:

📖 Formatting 4b53a6b


hr


RELEASE: 2.0.0


hr


RELEASE: 1.2.0


hr


RELEASE: 1.1.0

📦 NEW:

📦 First Draft v2.0.0 84b4f54
Avoid direct access to the lib 💯 368b951
📦 Emoji-log Badge 8c38efe

👌 IMPROVE:

👌 SSL + Image 7d1773d
👌 Better Ignore f2c15fe

🐛 FIX:

🐛 Sync .gitignore e9f9755

📖 DOC:

📖 Update wrt 2.0.0 de271b8
📖 Formatting cc3bbe6
📖 Formatting 79f00a3
📖 Install instructions 237667a
📖 Formatting 906d0e1
📖 Install instructions d147ff2
📖 Formatting 0d57aeb
📖 Formatting bb56bb9
📖 Format af06497
📖 Formatting 0c5cf04
📖 Heading 0fa3983
📖 Formatting 9f8bcb2


hr


RELEASE: 1.0.0



📃

License & Conduct


🙌

Connect

GitHub @AhmadAwais (follow) TO STAY UP TO DATE ON FREE & OPEN SOURCE SOFTWARE

Twitter @MrAhmadAwais (follow) TO GET ONE DEV MINUTE DAILY HOT TIPS & TROLLS

YouTube AhmadAwais (subscribe) TO TECH TALKS & ONE DEV MINUTE VIDEOS

Blog: AhmadAwais.com (read) MOSTLY LONG FORM TECHNICAL ARTICLES

LinkedIn @MrAhmadAwais (connect) WITH THE LINKEDIN PROFILE Y'ALL


👌

Me (Ahmad Awais) and my incredible wife (Maedah Batool) are two engineers who fell in love with open source and then with each other. You can read more about me here. If you or your company use any of my projects or like what I’m doing then consider backing me. I'm in this for the long run. An open-source developer advocate.


Node CLI

Or you can back me by checking out my super fun video course. After building hundreds of developer automation tools used by millions of developers, I am sharing exactly how you can do it yourself with minimum effective effort. Learn to build Node.js & JavaScript based CLI (Command Line Interface) apps. Automate the grunt work, do more in less time, impress your manager, and help the community. → I'm sharing it all in this online video course. Node CLI Automation without wasting a 1,000 hours


Node CLI


Support my work: If you or your company use any of my projects or like what I’m doing then consider backing me. I'm in this for the long run. An open-source developer advocate.

Sponsor Awais Node.js CLI Automation VSCode Follow @MrAhmadAwais on Twitter