A PHP wrapper for SignalAds's API

1.0.1 2023-01-28 11:47 UTC

This package is auto-updated.

Last update: 2025-03-29 01:17:03 UTC


README

Latest Stable Version Total Downloads

SignalAds RESTful API Document

If you need to future information about API document Please visit RESTful Document

Installation

After that you just need to pick API-KEY up from My Account section.

Use in these ways :

composer require signalads-co/php

or add

"signalads/php": "*"

And run following command to download extension using composer

$ composer update

Usage

  • Required Autoload
require __DIR__ . '/vendor/autoload.php';
  • Exception Handler
try{
	// call SignalAdsApi function
}
catch(\SignalAds\Exceptions\ApiException $e){
	// در صورتی که خروجی وب سرویس 200 نباشد این خطا رخ می دهد
	echo $e->errorMessage();
}
catch(\SignalAds\Exceptions\HttpException $e){
	// در زمانی که مشکلی در برقرای ارتباط با وب سرویس وجود داشته باشد این خطا رخ می دهد
	echo $e->errorMessage();
}
  • Send Single SMS
$api = new \SignalAds\SignalAdsApi( "API Key" );
$sender = "10004346";
$message = "خدمات پیام کوتاه سیگنال";
$receptor = "09123456789";
$api->Send($sender,$receptor,$message);

Sample Output

{
  "data": {
    "message_id": "28561b88-8403-45b8-a114-508abdb9c436",
    "price": 120
  },
  "message": "پیام شما با موفقیت در صف ارسال قرار گرفت",
  "error": {
    "message": null,
    "errors": null
  }
}
  • Send Multiple SMS With Same Text
$api = new \SignalAds\SignalAdsApi( "API Key" );
$sender = "10004346";
$message = "خدمات پیام کوتاه سیگنال";
$receptors = array("09123456789","09367891011");
$api->SendGroup($sender,$receptors,$message);

Sample Output

{
  "data": {
    "message_id": "55800454-fe52-44b3-9c44-43c87d6f29b2",
    "price": 240
  },
  "message": "پیام شما با موفقیت در صف ارسال قرار گرفت",
  "error": {
    "message": null,
    "errors": null
  }
}
  • Send Sms With Pattern
$api = new \SignalAds\SignalAdsApi( "API Key" );
$sender = "10004346";
$pattern_id = "10004346";
$pattern_params = ["param 1", "param 2"];
$receptors = array("09123456789","09367891011");
$api->SendPattern($sender,$pattern_id,$pattern_params,$receptors);

Sample Output

{
  "data": {
    "message_id": "28561b88-8403-45b8-a114-508abdb9c436"
  },
  "message": "پیام شما با موفقیت در صف ارسال قرار گرفت",
  "error": {
    "message": null,
    "errors": null
  }
}
  • Get Message Status
$api = new \SignalAds\SignalAdsApi( "API Key" );
$messageid=123;
$api->Status($messageid);
  • Get Message Status With Filter
$api = new \SignalAds\SignalAdsApi( "API Key" );
$messageid=123;
$limit=10;
$offset=0;
$status=1;
$receptor="09xxxxxxxxx";
$api->Status($messageid, $limit, $offset, $status, $receptor);

Statuses

PENDING = 1
SENDING = 2
BLACKLIST = 3
DELIVERED = 4
NOT_DELIVERED = 5
NOT_SENDING = 6
ERROR = 7

Sample Output

{
  "data": {
    "items": [
      {
        "number": "09xxxxxxxxx",
        "status": 1
      },
      {
        "number": "09xxxxxxxxx",
        "status": 2
      },
      {
        "number": "09xxxxxxxxx",
        "status": 3
      },
      {
        "number": "09xxxxxxxxx",
        "status": 4
      },
      {
        "number": "09xxxxxxxxx",
        "status": 5
      },
      {
        "number": "09xxxxxxxxx",
        "status": 6
      },
      {
        "number": "09xxxxxxxxx",
        "status": 7
      }
    ],
    "count": 7,
    "sum": 0
  },
  "message": null,
  "error": {
    "message": null,
    "errors": null
  }
}
  • Get account credit
$api = new \SignalAds\SignalAdsApi( "API Key" );
$api->GetCredit();

Sample Output

{
  "data": {
    "credit": 12345
  },
  "message": null,
  "error": {
    "message": null,
    "errors": null
  }
}
  • Get Package Price
$api = new \SignalAds\SignalAdsApi( "API Key" );
$api->GetPackagePrice();

Sample Output

{
  "data": {
    "id": 415,
    "gift_charge": "123",
    "price": "123",
    "name": "testsdf",
    "package_prices": [
      {
        "id": 156,
        "english_price": "210",
        "persian_price": "180",
        "operator": {
          "id": 1,
          "title": "همراه اول"
        }
      }
    ]
  },
  "message": null,
  "error": {
    "message": null,
    "errors": null
  }
}