Panacea Mobile Help Centre
  • 👋Welcome to Panacea Mobile!
  • Overview
    • Getting Started
    • Multipart SMS
    • Unicode Characters
    • SMS Delivery Statuses
      • Troubleshooting SMS Delivery
    • Compliance
    • FAQs
    • International SMS
      • 🚧Country Regulations & Requirements (under construction)
  • How To Guides
    • Panacea Mobile Dashboard
    • Send a single SMS
    • Send batch campaigns
    • Send personalised batch campaigns
    • Inbox
    • Inbound Triggers
    • SMS Numbers
    • Blocked Numbers & Opt-Outs
    • Sub Accounts
    • Reporting
    • Adding prepaid credits
    • Account Settings
      • My Profile
      • My Billing
      • Security
  • Developers
    • HTTPS API
      • Single Sends
      • Batch Sends
      • Delivery Reports via API
      • Receiving Inbound SMS
      • API Response Code
      • API Keys
      • Examples
        • PHP
          • PHP API Example
          • Simple SMS Send
          • Bulk SMS Send
          • Batch Create
          • Batch Create (.zip)
          • Message Status
        • Python
          • Python API Example
    • SMPP API
      • SMPP Connection Details
  • USSD
    • What is USSD?
    • USSD Campaigns
    • Integration with your server
  • Reseller Platform
    • Reseller Platform Features
    • Getting Started
    • Reseller Settings
    • Managing Your Customer Accounts
    • Branded Platform Example
    • FAQs
Powered by GitBook
On this page

Was this helpful?

  1. Developers
  2. HTTPS API
  3. Examples
  4. PHP

PHP API Example

?php 
/* Include PanaceaApi class */
require_once("panacea_api.php");

$api = new PanaceaApi();
$api->setUsername("demouser");
$api->setPassword("demouser");

$result = $api->message_send("27111234567", "Hello", "27111234456");

if($api->ok($result)) {
	echo "Message sent! ID was {$result['details']}\n";
	$message_id = $result['details'];
	
	/* Now we can check what the status of the message is */
	
	$message = $api->message_status($message_id);
	
	if($api->ok($message)) {
		echo "Message cost was {$message['details']['cost']}\n";
		echo "Message had {$message['details']['parts']} parts\n";
		echo "Message current status is {$message['details']['status']}\n";
	}
	
	/* Let's check our balance */
	
	$balance = $api->user_get_balance();
	
	if($api->ok($message)) {
		echo "Our current balance is {$balance['details']}\n";
	}
	
	$groups = $api->address_book_groups_get_list();
	
	/* Get a list of our batches */
	$batches = $api->batches_list();
	
	if($api->ok($batches)) {
		if(!empty($batches['details'])) {
			/* We have some batches, let's start the first one */
			
			$api->batch_start($batches['details'][0]['id']);
			
		}
	}
	
	
} else {
	/* There was an error */
	echo $api->getError();
}

?>
PreviousPHPNextSimple SMS Send

Last updated 1 year ago

Was this helpful?