Answer the question
In order to leave comments, you need to log in
Zend Framework 2 - Why can't I set parameters for curl?
I'm trying to assign a useragent, but it doesn't work. The user agent remains the default "Zend\\Http\\Client". What is the problem?
$useragent = 'Mozilla/5.0';
$adapter = new \Zend\Http\Client\Adapter\Curl();
$client = new \Zend\Http\Client($url);
$client->setAdapter($adapter);
$client->setMethod('GET');
$adapter->setOptions(array(
'curloptions' => array(
CURLOPT_USERAGENT => $useragent,
)
));
$respond = $client->send();
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question