Call file - Connect two calls

Hey guys I got this code and right now what it does it only calls the one extension.

// Change the values below to reflect your setup

$this_ip = “”;
$asterisk_outgoing = “/var/spool/asterisk/outgoing/”;
$asterisk_tmp = “/tmp/”;
$asterisk_toext = “5”; // the extension you want to call.

$asterisk_cid = “DOMOFON”; // the from caller id you’d like to display.

if ($remote_ip == $this_ip){
// create the file in a temp location
$file = “/$asterisk_tmp/call.txt”;
$call = fopen($file, ‘w’) or die(“can’t open file”);
$data = “Channel: SIP/$asterisk_toext\nExtension: s\nCallerID: $asterisk_cid\nWaitTime: 15”;
fwrite($call, $data);

    // chmod, chown and chgrp the file to asterisk:asterisk
    chmod ("/$asterisk_tmp/arduino_call.txt", 0666);
    chown ("/$asterisk_tmp/arduino_call.txt", "asterisk");
    chgrp ("/$asterisk_tmp/arduino_call.txt", "asterisk");

    // move the file to /var/spool/asterisk/outgoing
    rename("/$asterisk_tmp/call.txt", "/$asterisk_outgoing/");

echo “unauthorized access”;

What I’d like it to do now is call two numbers and connect them. I can’t manage to make it work

The structure is like this for just 1 call now and it hangs up should I answer:

$data = “Channel: SIP/$asterisk_toext\nExtension: s\nCallerID: $asterisk_cid\nWaitTime: 15”;

I can’t work our what you are trying to do. Your call file calls two devices, one in terms of an extension and one directly by the device name.