Setting user agent in curl using php

PHP curl library gives you an option to change the user agent. All you need to do is to add the following line of code to the other set of curl options:

curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows; U; Windows NT 6.1; rv:2.2) Gecko/20110201');

Basicly, you can set anything you want as a user agent. If you are trying to scrape websites, you can identify your bot as following:

curl_setopt($ch, CURLOPT_USERAGENT, 'CUSTOM PHP BOT');

Here is a list of user agents grouped by browser type and version: http://www.useragentstring.com/pages/useragentstring.php

- Posted by Eva to Php