GithubHelp home page GithubHelp logo

bvklim / herald-client-php Goto Github PK

View Code? Open in Web Editor NEW

This project forked from linkorb/herald-client-php

0.0 1.0 0.0 33 KB

Herald client for PHP - Library + CLI tools

License: MIT License

PHP 100.00%

herald-client-php's Introduction

Herald PHP client

Send beautiful messages from your application.

Installation

composer require herald-project/client-php

Example

use Herald\Client\Client as HeraldClient;
use Herald\Client\Message as HeraldMessage;

// get the client
$herald = new HeraldClient(
    '[herald api username]',
    '[herald api password]',
    '[herald server uri]',
    '[herald transport, e.g. smtp]')
);

// check template existance.
if ($herald->templateExists('signup')) {
    // get the message
    $message = new HeraldMessage();
    // use the template
    $message->setTemplate('signup');
    // set to address
    $message->setToAddress($emailAddress, $customerName);
    // populate data
    $message->setData('firstname', 'Hongliang');
    $message->setData('nickname', 'exploder hater');
    // send
    $herald->send($message);
}

CLI usage

#!/bin/sh

common_param="\
--username=api_username \
--password=api_password \
--apiurl=http://localhost:8787/api/v2 \
--account=test \
--library=test"

# get list of all contact lists
bin/herald-client list:list ${common_param}

# get list of contacts in contact list #1
bin/herald-client list:contacts ${common_param} --listId=1

# get list of segments for list #1
bin/herald-client list:segments ${common_param} --listId=1

# get available list_fields for list #1
bin/herald-client list:fields ${common_param} --listId=1

# delete contact #42
#bin/herald-client contact:delete ${common_param} --contactId=42

# get properties of contact #6
bin/herald-client contact:properties ${common_param} --contactId=6

# add new contact with address '[email protected]' to list #1
bin/herald-client contact:add ${common_param} --listId=1 [email protected]

# add new property to contact #36
bin/herald-client property:add ${common_param} --contactId=36 --listFieldId=4 --value="some value"

# send message based on tamplate #1 to all contacts in list #1
bin/herald-client list:send ${common_param} --listId=1 --templateId=1

# send message based on tamplate #1 to contacts in list #1 that meet the conditions for segment #6
bin/herald-client list:send ${common_param} --listId=1 --templateId=1 --segmentId=6

herald-client-php's People

Contributors

h-wang avatar joostfaassen avatar bvklim avatar

Watchers

 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.