API-Dokumentation

Wie sende ich SMS über API?

username - Benutzername
password - Passwort
sender - SMS-Absender
def_time - Zeit zum Senden von Massen-SMS, wenn nicht definiert, wird die aktuelle Zeit verwendet
id - Optionale eindeutige ID der SMS, die vom Kunden generiert wurde, Identifikation für Zustellbelege mit HTTP GET/POST-Methode
name - Optionaler Kundenname
idc - Optionale Kunden-ID, für den Export von Zustellbelegen in CSV, XLS
send_time - SMS-Versandzeit, übergeordnete def_time
unicode - SMS wird mit Diakritika gesendet
phone - Telefonnummer
text - SMS-Text
callback - Ein Zustellbeleg für SMS wird an die definierte URL gesendet. Es ist erforderlich, eine eindeutige Nachrichten-ID für die nachfolgende Zuweisung des Zustellstatus der SMS festzulegen

Príklad odoslania SMS

<?php 
define('XML_PAYLOAD', '<?xml version="1.0" encoding="UTF-8"?>
<sms>
    <credential>
        <username>username</username>
        <password>password or API key</password>
    </credential>
      <message>
        <sender>mycompany</sender>
        <def_time>2016-12-31 23:59:00</def_time>
        <recipients>
         <recipient>
            <id>121</id>  
            <unicode>0</unicode>
            <phone>421911123456</phone>
            <text>Text first SMS</text>
        </recipient>
            <recipient>
             <id>122</id>
             <send_time>2017-12-31 23:59:00</send_time>
             <unicode>1</unicode>
             <phone>421944123456</phone>
            <text>Text SMS 2 unicode čžýáíáť</text>
            </recipient>
            <recipient>
             <id>123</id>
             <name>Janko Hraško</name>
             <idc>12345</idc>
             <send_time></send_time>
             <unicode>0</unicode>
             <phone>42190512346</phone>
             <text>Text 3</text>
            </recipient>
        </recipients>
    </message>
    <optional>
             <callback>https://www.domain.com/sms/callback.php</callback>
    </optional>
</sms>'); 
define('XML_POST_URL', 'https://www.affilsms.com/api/sms-xml/'); 
$ch = curl_init(); 
curl_setopt($ch, CURLOPT_URL, XML_POST_URL); 
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); 
curl_setopt($ch, CURLOPT_TIMEOUT, 60); 
curl_setopt($ch, CURLOPT_POSTFIELDS, XML_PAYLOAD); 
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Connection: close')); 
$result = curl_exec($ch); 
if (curl_errno($ch) ) 
{ 
$result = 'ERROR -> ' . curl_errno($ch) . ':' . curl_error($ch); 
} 
else 
{ 
$returnCode = (int)curl_getinfo($ch, CURLINFO_HTTP_CODE); 
switch($returnCode) 
   { 
   case 200: $xmlObject = new SimpleXMLElement($result);   
             $status = $xmlObject->status; 
             $balance = $xmlObject->balance; 
             $errorsms = $xmlObject->errorsms;
             $failedsms = $xmlObject->failedsms;  
   break; 
   case 404: 
   $result = 'ERROR -> 404'; 
   break; 
   default: 
       } 
} 
curl_close($ch); 

?> 
 

 

XML-Antwort

<response>
<status>1</status>
<balance>64.2454</balance>
<sentsms>3</sentsms>
<errorsms></errorsms>
<failedsms></failedsms>
</response>

 

Status

1 Eingehender Anruf

- 1 Falsche Anmeldeinformationen

sentsms Anzahl der erfolgreich empfangenen SMS im System

errorsms Anzahl der nicht gesendeten SMS aufgrund falscher Nummern

failedsms Anzahl der nicht gesendeten SMS aufgrund niedriger Gutschrift

 

 

Zustellbelege -

status: status=delivered, undelivered

id: id=123456