HTTPS API Interface

Below we collected all the information needed to integrate your system or application with HQSMS, using the API interface. HTTPS API interface allows you to integrate most of on-line applications. You will find here a set of basic tools that will be helpful in integration.

HTTPS specification 3.4 (pdf version)
HTTPS extended functions 1.1 (pdf version)
HTTPS phonebook 1.1 (pdf version)

  • 1. Examples of sending SMS in PHP.

    Example 1 - Sending SMS using GET method.
    <?php

    $params 
    = array(
        
    'username' => 'username',          //username used in HQSMS
        
    'password' => md5('password'),     
        
    'to'       => '44123123123',       //destination number
        
    'from'     => "HQSMS.com",            //sender name have to be activated
        
    'message'  => "content of message",
    );
    if (
    $params['username'] && $params['password'] && $params['to'] && $params['message']) {
        
    $data '?'.http_build_query($params);
        
    $file fopen('https://ssl.hqsms.com/sms.do'.$data,'r');
        
    $result fread($file,1024);
        
    fclose($file);
        echo 
    $result;
    }
    ?>
    Example 2 - Sending SMS using POST method.
    <?php
    $username 
    'login';                      //username used in HQSMS
    $password md5('password');               
    $to '44123123123';                      //destination number
    $from "HQSMS.com";                        //sender name have to be activated
    $message "Message content";  
    $url 'https://ssl.hqsms.com/sms.do';
    $c curl_init();
        
    curl_setopt($cCURLOPT_URL$url);
        
    curl_setopt($cCURLOPT_POSTtrue);
        
    curl_setopt($cCURLOPT_POSTFIELDS'username='.$username.'&password='.$password.'&from='.$from.'&to='.$to.'&message='.$message);
        
    curl_setopt($cCURLOPT_RETURNTRANSFERtrue); 
        
    $content curl_exec ($c);
        
    curl_close ($c); 
    echo 
    $content;
    ?>
    Example 3 - Sending SMS using backup server.
    <?php
    function sms_send($params$backup false ) {

        static 
    $content;

        if(
    $backup == true){
            
    $url 'https://ssl2.smsapi.pl/sms.do';
        }else{
            
    $url 'https://ssl.smsapi.pl/sms.do';
        }

        
    $c curl_init();
        
    curl_setopt$cCURLOPT_URL$url );
        
    curl_setopt$cCURLOPT_POSTtrue );
        
    curl_setopt$cCURLOPT_POSTFIELDS$params );
        
    curl_setopt$cCURLOPT_RETURNTRANSFERtrue );

        
    $content curl_exec$c );
        
    $http_status curl_getinfo($cCURLINFO_HTTP_CODE);

        if(
    $http_status != 200 && $backup == false){
            
    $backup true;
            
    sms_send($params$backup);
        }

        
    curl_close$c );    
        return 
    $content;
    }

    $params = array(
         
    'username' => 'login',
         
    'password' => md5'haslo' ),
         
    'to' => '500000000',
         
    'from' => 'SMSAPI',
         
    'eco' => 0,
         
    'message' => "Moja wiadomosc",
    );

    echo 
    sms_send($params);
    ?>
  • 2. Sending WAP PUSH messages.

    In order to send WAP PUSH message you should add UDH and datacoding parameter &udh=0605040b8423f0, &datacoding=bin and content should be converted to binary. You can use our Tools to convert WAP PUSH message.
    Example:
    <?php
    $params 
    = array(
        
    'username' => 'username'//username used in HQSMS
        
    'password' => md5('password'),     
        
    'to' => '44123123123'//destination number
        
    'from' => "HQSMS.com"//sender name have to be activated
        
    'udh' => '0605040b8423f0'//UDH header of WAP Push message
        
    'datacoding' => 'bin'//switching message to binary
        //Binary message:
        
    'message' => '60601ae02056a0045c60c037777772E736D736170692E7
        06C000701035A61707261737A616D7920646F20736D734150492E706C000101'
    ,
    );
    if (
    $username && $password && $to && $message) {
        
    $data '?'.http_build_query($params);
        
    $file fopen('https://ssl.hqsms.com/sms.do'.$data,'r');
        
    $result fread($file,1024);
        
    fclose($file);
        echo 
    $result;
    }
    ?>
  • 3. Sending vCard messages.

    In order to send vCard message you should add UDH and datacoding parameter &udh=06050423f40000, &datacoding=bin and content should be converted to binary. You can use our Tools to convert vCard message.
    Example:
    <?php
    $params 
    = array(
        
    'username' => 'username'//username used in HQSMS
        
    'password' => md5('password'),     
        
    'to' => '44123123123'//destination number
        
    'from' => "HQSMS.com"//sender name have to be activated
        
    'udh' => '06050423f40000'//UDH header of vCard message
        
    'datacoding' => 'bin'//switching message to binary
        //Binary message:
        
    'message' => '424547494E3A56434152440D0A56455253494F4E3A322E310D0A464E3A4851534D53205
        36572766963650D0A4E3A536572766963653B4851534D533B3B3B0D0A54454C3B505245463B43454C4C3A343
        8203332203732302036392031300D0A454D41494C3B494E5445524E45543A737570706F7274406871736D732
        E636F6D0D0A55524C3A7777772E6871736D732E636F6D0D0A454E443A5643415244'
    ,
    );
    $data '?'.http_build_query($params);
    $plik fopen('https://ssl.hqsms.com/sms.do'.$data,'r');
    $wynik fread($plik,1024);
    fclose($plik);
    echo 
    $wynik;
    ?>
  • 4. Sending scheduled messages.

    In order to send message with schedlued time you need to use &date=unixtime parameter, date should be convertet to unixtime. You can use generator on our Tools page or use strtotime() PHP function. Messages can be scheduled up to 3 month from now.
    Example:
    <?php
    $params 
    = array(
        
    'username' => 'username'//username used in HQSMS
        
    'password' => md5('password'),     
        
    'to' => '44123123123'//destination number
        
    'from' => "HQSMS.com"//sender name have to be activated
        
    'message' => "content of message",
        
    'date' => strtotime('2012-03-25 11:00'), //Date when message should be sent
    );
    if (
    $username && $password && $to && $message) {
        
    $data '?'.http_build_query($params);
        
    $file fopen('https://ssl.hqsms.com/sms.do'.$data,'r');
        
    $result fread($file,1024);
        
    fclose($file);
        echo 
    $result;
    }
    ?>