2014-01-26 39 views
0
<?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屬性?如何更改goutte的guzzle屬性?

回答

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); 
+0

我不確定爲什麼你被低估了。我遇到了問題,以繞過一些ssl自我認證問題。我遵循你所說的,但是改變了('驗證','路徑/到/證書')到('驗證',假),它的工作就像一個魅力。 –