Topic: Website visitor announcing...?

Hi all,
I was just thinking last night that it would be cool if my rabbit announced when someone visited one of my websites.
Mucking around with the APi to get him to tell me when someone does is easy enough, but i'd like to embed the API URL string within the HTML of my webpage. So far I can't see how I can do this - especially as when you 'hit' the API you get a return/result page...

Anyone any ideas on this?

thanks,
Mark

Re: Website visitor announcing...?

I did it on http://nabzone.com , with a litlle php script. The server call the API each time a new visitor come in.
If you don't want or can't do it server side, I think you should use AJAX technology to do it.

Now in English too
www.nabzone.com,
coding, fun and games for your Nabaztag.

Re: Website visitor announcing...?

Hi, thanks!

Did you have that php script called from the webpage as it loaded, or did you load the webpage from the php script?

I can use php - i just couldn't see a way of calling the API (via PHP) from the index.htm (or whatever) file?

If it's not too cheeky, please could I see what you did with the php script?

smile

M.

Last edited by markharbord (2008-02-21 14:38:48)

Re: Website visitor announcing...?

Hi -

Make a PHP file that looks like this:

<?php
    $message = "Someone+is+visiting+your+website!";   
    $xml = simplexml_load_file("http://api.nabaztag.com/vl/FR/api.jsp?sn=(your serial)&token=(your token)&voice=lucy22k&tts=".$message);
?>


To call this from your web page, you'll need to add a little AJAX-like code:

function CallRabbitAPI()
{

var xmlHttp;
try
  {
  // Firefox, Opera 8.0+, Safari
  xmlHttp=new XMLHttpRequest();
  }
catch (e)
  {
  // Internet Explorer
  try
    {
    xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
    }
  catch (e)
    {
    try
      {
      xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
      }
    catch (e)
      {
      alert("Your browser does not support AJAX!");
      return false;
      }
    }
  }
 
    xmlHttp.open("GET","path to your PHP script",true);
    xmlHttp.send(null);
}


Then in your index.html, add this somewhere in your body:

<script>
CallRabbitAPI();
</script>

Re: Website visitor announcing...?

Thanks John, i'll give that a go!!

One question - the middle Ajax style bit - I take it that goes in the index.html file too? Anywhere in particular?

Cheers!
m.

Re: Website visitor announcing...?

Actually scratch that - it goes in <script> </script> tags in the header, right?

I'll go and give it a go now,

Thanks again!
M.

Re: Website visitor announcing...?

John,

Is that second " in the correct place in the second line of the php script?

Just wondering, cos it's not working - but then maybe the API is down or something....

Thx,
M

Re: Website visitor announcing...?

The Ajax script goes into the header, the function calling it into the body.

Yes, the path to the PHP goes in there..

Test it by going to the PHP script directly!

Last edited by JohnK (2008-02-21 17:11:47)

Re: Website visitor announcing...?

can someone check my site? I've been having nothing but issues... the nabzone messenger is not working correctly. I get a red flag, even though my tagtag reads aloud the message.

Nor does the website visitor announce work. Basically the simplexml_load_file function doesn't seem to be working properly in visitor.php. I don't know why....my server supports php.

http://mattkrizsan.com
http://mattkrizsan.com/visitor.php

NabName: Mattie

Re: Website visitor announcing...?

The PHP gives "Call to undefined function: simplexml_load_file() ", which implies you don't have a function called simplexml_load_file() 

So what version of PHP have you installed? Maybe you are using an old version, or haven't included any support for this function.

Perhaps you should try the iframe method of calling the rabbit api?  Check out my remoterabbit app for how to do that.

Re: Website visitor announcing...?

Hrm I had PHP 4 switched on under my hosting settings. I set it to PHP 5.20 and it still will not work....

although I don't seem to be getting that function error anymore.

Last edited by funkydude101 (2008-02-24 17:18:34)

NabName: Mattie