You can fake a user agent when using cURL, so it makes no sense depending on the sender of the user when you KNOW his cURL request.
For example: I recently wrote an application that receives pagerank URLs from Google. Now Google dislikes this, so it only allows a specific user agent to access its pagerank servers. Decision? Trick the user agent using cURL and Google won't get any wiser.
Moral of the story: cURL JUST NOT user agents are reliable.
If you still want to do this, you should be able to get the transferred user agent, as usual,
$userAgent=$_SERVER['HTTP_USER_AGENT'];
EDIT A quick test showed this:
dumpx.php:
<?php $url="http://localhost/dump.php"; $ch = curl_init(); curl_setopt($ch, CURLOPT_URL,$url); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1); if($_GET['u']==y) { curl_setopt($ch, CURLOPT_USERAGENT, "booyah!"); } curl_setopt($ch, CURLOPT_RETURNTRANSFER, 0); curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 2); curl_setopt($ch, CURLOPT_TIMEOUT, 60); //curl_setopt($ch, CURLOPT_CUSTOMREQUEST,'GET'); curl_setopt ($ch, CURLOPT_HEADER, 0); $exec=curl_exec ($ch); ?>
dump.php:
<?php var_dump($_SERVER); ?>
Case 1: http: //localhost/dumpx.php? U = y
'HTTP_USER_AGENT' => string 'booyah!' (length=7)
Case 2: http: //localhost/dumpx.php? U = n
No $ _SERVER ['HTTP_USER_AGENT']
This proves that there is no default user agent for curl: it just won't pass it in the request header