Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Hoiio API Example: Conference Outgoing
<title>Hoiio Conference API</title>
<body style="font-family:arial,helvetica,sans-serif;font-size:13px;margin-top:20px;">
// Developer information: appId, accessToken
$appId = "YOUR_APP_ID_HERE";
$accessToken = "YOUR_ACCESS_TOKEN_HERE";
$server = "";
// Exit PHP and print those UI
<h1>Hoiio Conference API</h1>
<form id="conference" name="conference" action="conf-example.php" method="post">
<p>Enter at least 1 destination phone number in E.164 format. Example: +6511111111</p>
<input name="n1" type="text" /><br>
<input name="n2" type="text" /><br>
<input name="n3" type="text" /><br>
<input name="n4" type="text" /><br>
<input name="n5" type="text" /><br>
<input name="n6" type="text" /><br>
<input name="n7" type="text" /><br>
<input name="n8" type="text" /><br><br>
<input id="makeCall" type="submit" value="Make Conference Call">
// Back to PHP
// String the destinations together, separated by comma
$dest = "";
for ($i=1; $i<=8; $i++) {
$val = $_POST['n'.$i];
if (strlen($val) > 0)
$dest .= $val . ',';
if (substr($dest, -1) == ',')
$dest = substr($dest, 0, -1);
// Call Hoiio Conference API
$params = array("app_id" => $GLOBALS['appId'],
"access_token" => $GLOBALS['accessToken'],
"dest" => $dest,
"room" => "myroom",
"tag" => "conference trial");
$data = http_build_query($params);
$response = do_post_request($GLOBALS['server']."/voice/conference", $data);
$result = json_decode($response);
if ($result->status != "success_ok")
echo "Error: " . $result->status . "<br>";
echo "Conference call is send out successfully<br>";
echo '<br><a href="conf-example.php">back</a><br>';
// Source adapted from
// This function will do the http post to the server, feel free to use different function of your desire
function do_post_request($url, $data) {
$params = array('http' => array(
'method' => 'POST',
'content' => $data
$ctx = stream_context_create($params);
$fp = @fopen($url, 'rb', false, $ctx);
if (!$fp) {
throw new Exception("Problem with $url, $php_errormsg");
$response = @stream_get_contents($fp);
if ($response === false) {
throw new Exception("Problem reading data from $url, $php_errormsg");
return $response;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment