I use http://www.sitemeter.com SiteMeter website meter for years now and had an idea which apparently David Smith (Sitemeter's Inventor) says IS in fact possible. However I really have no idea how this would be done and so I was hoping someone here could help?
I would like to find out how to write a PHP script that would be able to read Sitemeter's "who's online" amount and display it on my website.
For example: Let's say if I went into sitemeter (http://www.sitemeter.com/default.asp?ac ... &report=15) and it showed 24 people online. I would like the PHP script to see there is 24 listed and display "24" on the website.
Thanks.
Using PHP to read SITEMETER's "Who's online" - Pos
Moderator: General Moderators
-
camarosource
- Forum Commoner
- Posts: 77
- Joined: Sat Aug 03, 2002 10:43 pm
- feyd
- Neighborhood Spidermoddy
- Posts: 31559
- Joined: Mon Mar 29, 2004 3:24 pm
- Location: Bothell, Washington, USA
I typically use [php_man]curl[/php_man] or [php_man]file_get_contents()[/php_man] depending on what information and controls are needed. After the content is downloaded, I use [php_man]preg_match()[/php_man] or its siblings to extract the information I need. Remember to get SiteMeter's permission to extract page information and display it on your site. 
-
camarosource
- Forum Commoner
- Posts: 77
- Joined: Sat Aug 03, 2002 10:43 pm
-
camarosource
- Forum Commoner
- Posts: 77
- Joined: Sat Aug 03, 2002 10:43 pm
I posted the question on a msgboard and someone told me about SNOOPY and wrote a small script that would read http://www.sitemeter.com 's who's online list and dislplay the number of people using your SNOOPY.
This is the small files he wrote:
[WHOISONLINE.PHP]
I placed it (and ALL the snoopy files) into the http://camarosource.ca/php/snoopy/
http://camarosource.ca/php/snoopy/whoisonine.php
But when you run it, it says "Users online : 0"
Obviously it is not reading the who's online list. I am guessing it is perhaps because you have to log INTO sitemeter? If this is the case, how would I make it so it logs in? In order to log into your Sitemeter account to see your site's stats, you have to enter your username and password.
Please help.
Thanks a LOT!
This is the small files he wrote:
[WHOISONLINE.PHP]
Code: Select all
<?php
<?php
include ("snoopy.class.php");
$url = "http://www.sitemeter.com/default.asp?action=stats&site=sm4camarosource&report=15";
$online_count = 0;
// Create a new instance of the Snoopy Class.
$snoopy = new Snoopy;
// Fetch all the links from the desired website.
$snoopy->fetchlinks($url); // Fetch all the links from the given URI.
// Now we will sift through all the links to find just the one we need.
$haystack = $snoopy->results; // This is an array containing all the links from fetchlinks.
reset($haystack);
while (list($key, $val) = each($haystack))
{
if (stristr($val,"&visit="))
{
$online_count++;
}
}
//display info
echo "Users online : $online_count";
?>
?>http://camarosource.ca/php/snoopy/whoisonine.php
But when you run it, it says "Users online : 0"
Obviously it is not reading the who's online list. I am guessing it is perhaps because you have to log INTO sitemeter? If this is the case, how would I make it so it logs in? In order to log into your Sitemeter account to see your site's stats, you have to enter your username and password.
Please help.
Thanks a LOT!