What I an wanting to do here is have the script email me when the user count reaches X number of listeners on my RR Scanner Feed.
Is This Possible?

<?php
    $filename = '<script language="JavaScript" src="http://api.radioreference.com/audio/listeners.php?feedId=10734"></script>'; 
    $fp = fopen( $filename,"r"); 
    if ($filename >= X) {
  //// ($email Me @ My Email Address Or Any Address I Add Here) ////
  exit();
}                       
    fclose( $fp ); 
    print "Online=$filename";   
?>

You'd have to store the file open count somewhere (file/database), but you would need a decrement too when sombody stops using it.

You'd have to store the file open count somewhere (file/database), but you would need a decrement too when sombody stops using it.

Thanks I see what you are saying I have found this code here but for the life of me I cant figure out how to get it to read the above mentioned

$filename = '<script language="JavaScript" src="http://api.radioreference.com/audio/listeners.php?feedId=10734"></script>';

and get it to write to a txt file.

<?php
    $filename = "PHPCounter.txt"; 
    $fp = fopen( $filename,"r");             
    $Old = fread($fp, 100);
    fclose( $fp );
    $Old = split ("=", $Old, 5);        
    $NewCount = $Old[1] + '1';        
    $New = "Online=$NewCount";        
    $fp = fopen( $filename,"w+");         
    if (flock($fp, 2)) { 
      fwrite($fp, $New, 100);
    }         
    fclose( $fp );

    print "Online=$NewCount";     
?>

What do you want with that script tag ?

What I am wanting is have the script email me when the user count reaches X number of listeners on my RR Scanner Feed.
So it would read the file

$filename = '<script language="JavaScript" src="http://api.radioreference.com/audio/listeners.php?feedId=10734"></script>';

and write it to a txt file and then email me when the listener count reaches X number if listeners.

That script is hosted by another party, and you want to read the number it returns in the document.write ? And based on that number send an email ?

That script is hosted by another party, and you want to read the number it returns in the document.write ? And based on that number send an email ?

pritaeas, Yes sir that is correct.

I think this should do it (can't test right now):

$filename = "http://api.radioreference.com/audio/listeners.php?feedId=10734";
$data = file_get_contents($filename);
preg_match('/document\.write\(\'(.*?)\'\);/i', $data, $result)
$listeners = $result[1];
echo $listeners;

Thank you so much. That was it and works great its nice to come on here and always get the help needed. its people like you that make Daniweb what it is today, Thanks again for the help..

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.