如何改变goutte的guzzle属性?

时间:2014-01-26 16:03:01

标签: php guzzle goutte

<?php
require_once '/var/www/goutte.phar';
 use Goutte\Client; 


 $guzzle = parent::getClient(); //You'll want to pull the Guzzle client out of Goutte to inherit its defaults
$guzzle->setDefaultOption('verify', '/path/to/cacert.pem'); //Set the certificate at @mtdowling recommends
$client->setClient($guzzle); //Tell Goutte to use your modified Guzzle client 

$crawler = $client->request('GET', 'https://ocean.ac-guadeloupe.fr/publinet/resultats'); //Proceed as you were
var_dump($crawler);
?>

当我运行上面的代码时,我收到错误“当没有类范围处于活动状态时无法访问父::”。那么如何从Goutte访问Guzzle房产?

1 个答案:

答案 0 :(得分:0)

示例的开头似乎假设您正在编写Goutte Client类的扩展。如果您只是使用该类,则代码段更像是:

$client = new Client();
$guzzle = $client->getClient(); //You'll want to pull the Guzzle client out of Goutte to inherit its defaults

$guzzle->setDefaultOption('verify', '/path/to/cacert.pem'); //Set the certificate at @mtdowling recommends
$client->setClient($guzzle); //Tell Goutte to use your modified Guzzle client 

$crawler = $client->request('GET', 'https://ocean.ac-guadeloupe.fr/publinet/resultats'); //Proceed as you were
var_dump($crawler);