當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Client::getCookieJar方法代碼示例

本文整理匯總了PHP中Goutte\Client::getCookieJar方法的典型用法代碼示例。如果您正苦於以下問題:PHP Client::getCookieJar方法的具體用法?PHP Client::getCookieJar怎麽用?PHP Client::getCookieJar使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Goutte\Client的用法示例。


在下文中一共展示了Client::getCookieJar方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: testUsesCookies

 public function testUsesCookies()
 {
     $guzzle = $this->getGuzzle();
     $client = new Client();
     $client->setClient($guzzle);
     $client->getCookieJar()->set(new Cookie('test', '123'));
     $crawler = $client->request('GET', 'http://www.example.com/');
     $request = $this->historyPlugin->getLastRequest();
     $this->assertEquals('123', $request->getCookie('test'));
 }
開發者ID:469306621,項目名稱:Languages,代碼行數:10,代碼來源:ClientTest.php

示例2: testUsesCookiesWithCustomPort

 public function testUsesCookiesWithCustomPort()
 {
     $guzzle = $this->getGuzzle();
     $client = new Client();
     $client->setClient($guzzle);
     $client->getCookieJar()->set(new Cookie('test', '123'));
     $client->request('GET', 'http://www.example.com:8000/');
     $request = end($this->history)['request'];
     $this->assertEquals('test=123', $request->getHeaderLine('Cookie'));
 }
開發者ID:fabpot,項目名稱:goutte,代碼行數:10,代碼來源:ClientTest.php

示例3: testFileCookieJar

 public function testFileCookieJar($testSaveSessionCookie = false)
 {
     $guzzle = $this->getGuzzle();
     $client = new Client();
     $client->setClient($guzzle);
     $filename = tempnam('/tmp', 'file-cookies');
     $jar = new FileCookieJar($filename, $testSaveSessionCookie);
     $client->setGuzzleCookieJar($jar);
     $client->getCookieJar()->set(new Cookie('test', '123'));
     $client->getCookieJar()->set(new Cookie('foo', 'bar', time() + 1000));
     $client->request('GET', 'http://www.example.com/');
     // Call to destruct method manually to test saving cookies
     $jar->__destruct();
     // Make sure it wrote to the file
     $contents = file_get_contents($filename);
     $this->assertNotEmpty($contents);
     // Load the cookieJar from the file
     $cookieJarReloaded = new FileCookieJar($filename);
     if ($testSaveSessionCookie) {
         $this->assertEquals(2, count($cookieJarReloaded));
     } else {
         $this->assertEquals(1, count($cookieJarReloaded));
     }
     unlink($filename);
 }
開發者ID:hoducha,項目名稱:Goutte,代碼行數:25,代碼來源:ClientTest.php

示例4: __construct

 /**
  * Constructor
  */
 public function __construct()
 {
     $this->client = new Client();
     // @FIXME without this Cookie the website serves a JavaScript only version - see known issues
     $this->client->getCookieJar()->set(new Cookie('TS017d4e39', '01e0f702cf037f97362f62278696546776e7b67bec0aece008837daa4d94f77fe53d7d4c8a6fa39200300641d6aee20da460dd376505f7550bd18461d59d5c2489e7bc515b97917c372e044bb84fb8441a011139863d71d7b41a83ffdab5f7f5dc3492855c362d61bdddc129cdd1d60c4ac9a1b702547433a79abd2e4c7c9a2f9f21e7c748fe9f995fea959736b5aea76fe14d45d2181a39b1f45823787c1cd69e0457f53c'));
 }
開發者ID:peterhough,項目名稱:sainsburys,代碼行數:9,代碼來源:Scraper.php


注:本文中的Goutte\Client::getCookieJar方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。