How To Use PHP CURL To Pass USERAGENT

I am going to use PHP curl to retrieve the web page with custom user-agent, How can I do to pass the custom user-agent?

You can use CURLOPT_USERAGENT to pass custom user-agent via php CURL

$url="http://www.domain.com/api";
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,$url);
curl_setopt($ch, CURLOPT_USERAGENT, "custom user-agent");
$exec=curl_exec ($ch);
0 0 votes
Article Rating
Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments