Has anyone done this before? We are looking for an example page
(preferably in PHP) that demonstrates how to do this.
I see in the documentation that someone has done it:
// Example - Using a cross-domain proxy
var hub = new StreamHub();
hub.connect("http://www.server.com/proxy.php?request=");
So apparently I am missing the proxy.php code.
In the meanwhile, I will try to make one and post it when I am done.
Thanks!
We have an old proxy.php script below that used curl. The API has
changed slightly, so you may need to adapt it, but here it is:
<?php
header("Expires: Thu, 1 Jan 1970 00:00:00 GMT");
header("Cache-Control: no-store, no-cache, must-revalidate");
header("Pragma: no-cache");
$ch = curl_init();
$url = $_GET["url"];
$domain = $_GET["domain"];
$userAgent = $_SERVER['HTTP_USER_AGENT'];
if (isset($_GET["subscribe"])) {
$subscribe = $_GET["subscribe"];
curl_setopt ($ch, CURLOPT_URL, "http://otherhost.com/" . $url .
"&domain=" . $domain . "&subscribe=" . $subscribe);
} elseif (isset($_GET["domain"])) {
curl_setopt ($ch, CURLOPT_URL, "http://otherhost.com/" . $url .
"&domain=" . $domain);
} else {
curl_setopt ($ch, CURLOPT_URL, "http://otherhost.com/" . $url);
}
curl_setopt ($ch, CURLOPT_USERAGENT, $userAgent);
curl_setopt ($ch, CURLOPT_HEADER, 0);
curl_exec ($ch);
curl_close ($ch);
?>
It was used like so:
hub.connect("http://www.server.com/proxy.php?url=");
Hope this helps,
Please post if you come up with something better.
Thanks.
I modified your proxy file to reflect the new StreamHub API but I am
still having trouble getting it to work. It seems to die right after
the first hidden iframe request goes out (and comes back) - it is
executing its code to set the window.x = window.parent.x functions on
the returned page - but nothing after that. I will continue to debug
it.
Here is what the file looks like now:
<?php
header("Expires: Thu, 1 Jan 1970 00:00:00 GMT");
header("Cache-Control: no-store, no-cache, must-revalidate");
header("Pragma: no-cache");
$ch = curl_init();
$url = $_GET["url"];
$domain = $_GET["domain"];
$r = $_GET["r"];
$topic = $_GET["topic"];
$userAgent = $_SERVER['HTTP_USER_AGENT'];
if (strncmp($url,"subscribe/",10) == 0)
{
curl_setopt ($ch, CURLOPT_URL, "http://www.imvox.com:7878/" .
$url . "&domain=" . $domain . "&r=" . $r . "&topic=" . $topic);
}
else
{
curl_setopt ($ch, CURLOPT_URL, "http://www.imvox.com:7878/" .
$url . "&domain=" . $domain . "&r=" . $r );
}
curl_setopt ($ch, CURLOPT_USERAGENT, $userAgent);
curl_setopt ($ch, CURLOPT_HEADER, 0);
curl_exec ($ch);
curl_close ($ch);
?>
In the meanwhile, an elegant solution to this cross domain ajax
problem is to just use an <iframe> tag to allow the StreamHub enabled
page to function without messing with proxies and other such things.
We put html code like this in the end user's page:
<iframe name="imvox_widget" src="http://www.imvox.com/imvox_status.php?
server=TestServer&css=160_light" frameborder="0" style="height:570px;
width:160px; "></iframe>
This allows any web page to embed our widget and see their real-time
voice chat server updates. The user just needs to pass in their own
server name.
You can check it out live at:
http://whatisnoise.com/
or go to the page directly:
http://www.imvox.com/imvox_status.php?server=TestServer&css=160_light
Thanks again!