npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

send-php-api

v6.0.0

Published

Sendy PHP API Wrapper: Complete API interfacing

Downloads

7

Readme

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'     => '[email protected]', // 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( '[email protected]' );

Method #3: Subscriber Status

$responseArray = $sendy->subStatus( '[email protected]' );

Method #4: Delete Subscriber

$responseArray = $sendy->delete( '[email protected]' );

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'           => '[email protected]',
		'reply_to'             => '[email protected]',
		'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

👌

Sponsor

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