Setting up a Php user agent for the script

The below post would explain how to set up a user agent for the script..

User agent is useful such that when you are indexing a site you are posed as a normal user instead of bot something like that..it can be used in proxies to a great extent..

To add useragent who can do this

a).htaccess method

.htaccess (Did n’t test it)

Add the following line to your .htaccess file and that should do the trick:
php_value user_agent Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.9) Gecko/20071025 Firefox/2.0.0.9

b)PHP set (This works great)
You could also use an ini_set to define the user agent too, just place this PHP line into the head of the script doing the Curl:

ini_set(’user_agent’, ‘Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.9) Gecko/20071025 Firefox/2.0.0.9′);

In the above line you are setting a useragent wo is using windows and firefox..User agent variables can be got the by the script easily..

This entry was posted on Tuesday, February 24th, 2009 at 9:58 pm and is filed under Php. You can follow any responses to this entry through the RSS 2.0 feed. You can skip to the end and leave a response. Pinging is currently not allowed.

Post a Comment