PHP code example of weezqydy / sematimeapi

1. Go to this page and download the library: Download weezqydy/sematimeapi library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

weezqydy / sematimeapi example snippets


// Include the composer autoloader if its not included yet
recipients
        $recipients = ['1234567890','0987654321','6789054321'];
        // Initialize The Sematime Api
        $gateway = new Sematime();
        //Create Your Message
        $message='A nice message send using Sematime';      
        $results = $gateway->AddTo($recipients)->message($message)->send();
        // if evrything goes well you will get a response from Sematime
        echo $results;
        
 

     //you can chain the parameters in any order
    $sema->message('message to send')->addTo(['1234567890'])->salutation('Dear')->send();

  // all these methods are chainable
    $sema->signature('Sent by The Sematime team. Call 0706129100')
         ->senderId('Sematime') // Use this option only if you have an existing  ID
         ->scheduledTime('1466683660000') // Must be a future timestamp
         ->callbackUrl('https://api.mydomain.com/callback') // must be an existing and Valid URL
         ->extra('extra=extra data') // Only accepts strings 
         ->addTo(array('1234567890')) // addTo expects an array of recipients
         ->message('an awesome message')
         ->send(); // send the message

    $sema = new Sematime\Api\Sematime();
    $scheduled= $sema->getAllScheduled(); // returns the first 20 scheduled messages

    /* retrieve more scheduled messages or retrieve from a certain point.*/
    $startFrom = 15;
    $fetch=40;
    // retrieves 40 messages starting form the 15th
     $scheduled= $sema->getAllScheduled($fetch, $startFrom);
     print $scheduled;


         use Sematime\Api\Sematime;      
        // Initialize The Sematime Api
        $sema = new Sematime();
        $response=$sema->groupName('My Group') // the group name you wish to add contacts
                       ->addId('1') // contact id for the contact you want to add
                       ->addName('John Doe') // a name for your contact 
                       ->addPhone('1234567890') // phone number you wish to add
                       ->save(); // finally save your contact
          print  $response; // {"statusCode":200, "description":"Contacts added successfully.","totalContacts":1, "contactsAdded":1}
 

    use Sematime/Api/Sematime;

    $sema= new Sematime();
    $group = 'My Group'; // The group you want to get contacts;
    $contacts= $sema->getGroupContacts($group); // you will get a json formated string of your contacts


    use Sematime/Api/Sematime;

    $sema= new Sematime();
    $group = 'My Group'; // The group you want to get contacts;
    $contactId= '14578652';
    $contacts= $sema->getContacts($contactId, $group); // you will get a json formated string of the contact


    use Semamatime/Api/Sematime;

    $sema= new Sematime();

    $contactId = '145367'; // provide the contact id to edit this e for contact optional
    $newPhoneNumber = '1234567890';  // New phone Number to the contact, optional

    $response= $sema->editContact($constactId, $group, $newName, $newPhoneNumber);
     echo $response; // Contact updated successfully.
            


 use Semamatime/Api/Sematime;

    $sema= new Sematime();

    $contactId = '145367'; // provide the contact id to edit this ($contactId, $group);
    echo $response; // Contact Deleted successfully