PHP code example of blacksenator / mini-sip4fb

1. Go to this page and download the library: Download blacksenator/mini-sip4fb 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/ */

    

blacksenator / mini-sip4fb example snippets


<?PHP

e_once './src/sipSocket2fb.php';

use blacksenator\miniSIP4fb\miniSIP4fb;

$softPhone = new miniSIP4fb('name', 'password');
$softPhone->registerPhone();                            // initial Registration
while (true) {
    $softPhone->refreshRegistration();
    // the FRITZ!Box sets an expiration of 300 sec.
    if (!$number = $softPhone->perceiveCall()) {
        continue;
    }
    // this is the part where you decide whether the incoming call should be terminated
    if ($number !== $should_be_terminated) {
        continue;
    }
    // miniSIP4fb tries to accept the call
    if (!$softPhone->pickUpCall($number)) {
        continue;
    }
    // miniSIP4fb was able to answer the call; no other phone rings anymore - if it even rang anywhere else
    if ($softPhone->hangUp($number)) {
        echo "Connection with $number terminated\r\n";
    }
}
$softPhone->closeSocket();