How to check for media player using HTTP_USER_AGENT
Hi all i want to write a php script that if only the request came from media player it work other wise it gives an error massage .for example if the request came from get or post or direct url execution in browser addrres i want it to send error message. I be happy if some one show me how to check for media players. I just do not know how to check for agent.Thanks
Code:
if($_SERVER['HTTP_USER_AGENT']=="your_user_agent")
{
//load your file
}
else
{
//load the error message
}
Re: How to check for media player using HTTP_USER_AGENT
Using the user agent field is always a bit flaky, but you could try this
PHP Code:
$ua = $_SERVER['HTTP_USER_AGENT'];
if (strpos($ua, 'Windows-Media-Player') || strpos($ua, 'NSPlayer')) {
// Windows Media Player
}
else if (strpos($ua, 'RealMedia')) {
// RealPlayer
}
I don't know of any more unfortunately.
Re: How to check for media player using HTTP_USER_AGENT
Thank u for u reply. Do u think the is the way they write it with - and no space ?The reason that i ask that my php be able to check for correct names. Furtheremore, could i us protocol in the same way ? for example http RealMedia file.