<?php
$d 
= new DBusDBus::BUS_SYSTEM );
$smsInterface $d->createProxy(
    
'org.freesmartphone.ogsmd'
    
'/org/freesmartphone/GSM/Device',
    
'org.freesmartphone.GSM.SMS'
);

if ( 
strlen$text ) <= 160 )
{
    
$smsInterface->SendMessage(
        
$nr,
        
$text,
        new 
DBusDictDbus::VARIANT,array() )
    );
    echo 
"Sending: $text\n";
}
else
{
    
$textParts chunk_split$text140"\n" );
    
$textParts explode"\n"trim$textParts ) );
    
$id mt_rand0255 );
    
$cnt count$textParts );
    
$c 1;
    foreach( 
$textParts as $textPart )
    {
        
$smsInterface->SendMessage(
            
$nr,
            
$textPart,
            new 
DBusDictDbus::VARIANT,
                array( 
                    
'csm_id' => new DBusVariant$id ),
                    
'csm_num' => new DBusVariant$cnt ),
                    
'csm_seq' => new DBusVariant$c )
                )
            ) 
        );
        
$c++;
        echo 
"Sending: $textPart\n";
    }
}
?>