curl - How to send Cookie using PHP Goutte -


i have code in php goutte

$client = new guzzlehttp\client([         'base_uri' => 'http://www.yellowpages.com.au',         'cookies' => true,         'headers' =>  [             'accept'          => 'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8',             'accept-encoding' => 'zip, deflate, sdch',              'accept-language' => 'en-us,en;q=0.8',              'cache-control'   => 'max-age=0',             'user-agent'      => 'mozilla/5.0 (x11; ubuntu; linux x86_64; rv:47.0) gecko/20100101 firefox/47.0'         ]     ]); 

i want send custom cookie server

usually way using simple curl

$a_curl_opts = array(     curlopt_nobody => 0,     curlopt_returntransfer => 1,     curlopt_cookiefile => $file_cook,     curlopt_cookiejar => $file_cook, ); curl_setopt_array($curl_init, $a_curl_opts); 

and saw somewhere thing in goutte

$client->getclient()->setdefaultoption('config/curl/'.curlopt_cookiefile, $file_cook);  $client->getclient()->setdefaultoption('config/curl/'.curlopt_cookiejar, $file_cook);  

but getting error.

catchable fatal error: argument 3 passed guzzlehttp\client::request() must of type array, string given, called in d:\ampps\www\gum\vendor\guzzlehttp\guzzle\src\client.php on line 87 , defined in d:\ampps\www\gum\vendor\guzzlehttp\guzzle\src\client.php on line 126 

try :

 $client = new \guzzlehttp\client(array(              'curl' => array(                  curlopt_cookiefile => $cookie_file,                  curlopt_cookiejar => $cookie_file,                  curlopt_returntransfer  => 1              ),              'cookies' => true          )); 

Comments

Popular posts from this blog

gridview - Yii2 DataPorivider $totalSum for a column -

java - Suppress Jboss version details from HTTP error response -

Sass watch command compiles .scss files before full sftp upload -