Giter Club home page Giter Club logo

aspsms's Introduction

SMS wrapper class for ASPSMS

Latest Stable Version Total Downloads

A very simple to use sms sending class for the aspsms.com gateway.

Installation

The recommended way to install is through Composer:

composer require nadar/aspsms

Usage

<?php

use Aspsms\Aspsms;

// create object class with originator option
$aspsms = new Aspsms('<YOUR_KEY>', '<YOUR_PASSWORD>', array(
    'Originator' => '<MY_SENDER_NAME>'
));

// set message and recipients with tracking their individual tracking numbers.
// attention: verify your tracking numbers first with $aspsms->verifyTrackingNumber(..);
$send = $aspsms->sendTextSms('<YOUR_SMS_MESSAGE>', array(
    '<TRACKING_NR1>' => '<MOBILE_PHONE_NR1>',
    '<TRACKING_NR2>' => '<MOBILE_PHONE_NR2>',
    '<TRACKING_NR3>' => '<MOBILE_PHONE_NR3>'
));

// the message was rejected by aspsms or your authentication credentials where wrong.
if (!$send) {
    echo "[ASPSMS] Error while sending text message: " . $aspsms->getSendStatus();
}

// aspsms takes a little time to delivery your message. You can also send the message and
// store the tracking numbers in a database, so you could retrieve the delivery status later.
sleep(10);

// get deliver status response
$status1 = $aspsms->deliveryStatus('<TRACKING_NR1>');
$status2 = $aspsms->deliveryStatus('<TRACKING_NR2>');
$status3 = $aspsms->deliveryStatus('<TRACKING_NR3>');

var_dump($status1, $status2, $status3);

Contributing

Quick guide:

  • Fork the repo.
  • Install dependencies: composer install.
  • Make changes.
  • If you are adding functionality or fixing a bug - Please add a unit test!
  • Ensure coding standards.

Unit Tests

In order to run the test suite, install the development dependencies:

composer install

Rename the phpunit.xml.dist file to phpunit.xml, then uncomment the following lines and add your const values:

<php>
    <!--<const name="USER_KEY" value="" />-->
    <!--<const name="USER_PASS" value="" />-->
    <!--<const name="SMS_NUMBER" value="" />-->
    <!--<const name="SMS_TRACKING" value="" />-->
</php>

Test your code with the following command:

./vendor/bin/phpunit

Run the coding standard fixer before send a new pull request.

./vendor/bin/php-cs-fixer fix src/

You're done. Thanks!

aspsms's People

Contributors

amyshko avatar mergemarc avatar nadar avatar sgry avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

aspsms's Issues

Aspsms\Exception

Hi

I get the following Exception:

Aspsms\Exception Object ( [message:protected] => Error while printing the response code into sendStatus. ResponseCode seems not valid. Response: "StatusCode:8" [string:Exception:private] => [code:protected] => 0 [file:protected] => /Applications/MAMP/htdocs/myvbc/vendor/nadar/aspsms/src/Aspsms.php [line:protected] => 227 [trace:Exception:private] => Array ( [0] => Array ( [file] => /Applications/MAMP/htdocs/myvbc/libs/framework/helper.php [line] => 55 [function] => sendTextSms [class] => Aspsms\Aspsms [type] => -> [args] => Array ( [0] => XXX [1] => Array ( [0] => xxx xxx xx xx ) ) ) [1] => Array ( [file] => /Applications/MAMP/htdocs/myvbc/pages/auth.page.php [line] => 62 [function] => sendSMS [class] => MyHelper [type] => :: [args] => Array ( [0] => myVBC [1] => xxx xxx xx xx [2] => "XXX" ) ) [2] => Array ( [file] => /Applications/MAMP/htdocs/myvbc/libs/framework/page.php [line] => 231 [function] => createAccessAction [class] => PageAuth [type] => -> [args] => Array ( ) ) [3] => Array ( [file] => /Applications/MAMP/htdocs/myvbc/libs/framework/application.php [line] => 33 [function] => work [class] => MyPage [type] => -> [args] => Array ( ) ) [4] => Array ( [file] => /Applications/MAMP/htdocs/myvbc/index.php [line] => 125 [function] => run [class] => MyApplication [type] => :: [args] => Array ( ) ) ) [previous:Exception:private] => )

But Status Code 8 seems not valid

    /**
     * Response status codes when you send an sms
     *
     * @var array
     */
    private $sendStatusCodes = array(
        1 => "Ok",
        3 => "Authorization failed (wrong userkey and/or password).",
        5 => "Not enough Credits available.",
    );

What's wrong? Where do I find all possible status codes?

PHPDocs

Provider better and IDE usable PHPDocs for properties and class descriptions.

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.