0

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";   
?>
2
Contributors
8
Replies
9
Views
5 Years
Discussion Span
Last Post by wxflint
0

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

0

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";     
?>
0

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.

0

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 ?

0

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.

0

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..

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.