2016-07-19 17 views
0

ich diesen Code in PHP Goutte senden habenWie Plätzchen mit 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' 
     ] 
    ]); 

Ich möchte meinen benutzerdefinierten Cookie-Server senden

Normalerweise ich es auf diese Weise cURL tun einfach

$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); 

Und ich sah dieses Ding irgendwo in Goutte

$client->getClient()->setDefaultOption('config/curl/'.CURLOPT_COOKIEFILE, $file_cook); 
$client->getClient()->setDefaultOption('config/curl/'.CURLOPT_COOKIEJAR, $file_cook); 
zu tun 10

Aber ich bekomme diesen Fehler.

Catchable fatal error: Argument 3 passed to GuzzleHttp\Client::request() must be of the type array, string given, called in D:\Ampps\www\gum\vendor\guzzlehttp\guzzle\src\Client.php on line 87 and defined in D:\Ampps\www\gum\vendor\guzzlehttp\guzzle\src\Client.php on line 126 

Antwort

0

Versuchen Sie folgendes:

$client = new \GuzzleHttp\Client(array(
      'curl' => array(
       CURLOPT_COOKIEFILE => $cookie_file, 
       CURLOPT_COOKIEJAR => $cookie_file, 
       CURLOPT_RETURNTRANSFER => 1 
      ), 
      'cookies' => true 
     ));