当前位置: 首页>>代码示例>>PHP>>正文


PHP Client::getRequest方法代码示例

本文整理汇总了PHP中Goutte\Client::getRequest方法的典型用法代码示例。如果您正苦于以下问题:PHP Client::getRequest方法的具体用法?PHP Client::getRequest怎么用?PHP Client::getRequest使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Goutte\Client的用法示例。


在下文中一共展示了Client::getRequest方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: getRequest

 /**
  * @return null|Request
  */
 protected function getRequest()
 {
     if (!$this->client) {
         return null;
     }
     return $this->client->getRequest();
 }
开发者ID:brennantom,项目名称:hackazon,代码行数:10,代码来源:WebTestCase.php

示例2: loginToOrange

 /**
  * Call orange portal and submit credentials
  * @return [type]      [description]
  */
 protected function loginToOrange()
 {
     $config = $this->getHelperSet()->get('config');
     $this->outputMessage('Login to orange wifi ...');
     // Forge form submit as there is no button or input
     $parameters = array('username' => $config['login'], 'password' => $config['pass'], 'isCgu' => 'true', 'code' => 0, 'lang' => 'fr', 'auth' => 1, 'restrictedCode' => '', 'restrictedProfile' => 0, 'restrictedRealm' => '', 'originForm' => 'true', 'tab' => '1');
     try {
         $client = new Client();
         $crawler = $client->request('POST', 'https://hautdebitmobile.orange.fr:8443/home/wassup', $parameters);
     } catch (\Exception $e) {
         $this->outputError('Connection error : ' . $e->getMessage(), true);
         exit(1);
     }
     // If login is a success, we should have follow the redirect to orange home page
     if ($client->getRequest()->getUri() == 'http://www.orange.fr') {
         $this->outputMessage('Login success !');
     } else {
         $error_mssg = 'Login failed';
         $div_error = $crawler->filterXPath("//div[@id='loginFormWassupErrorMessage']");
         if ($div_error->count() == 1) {
             $error_mssg .= ' : ' . trim($div_error->text());
         }
         $this->outputError($error_mssg);
         // Output raw reponse if (-vv)
         if ($this->output->getVerbosity() > OutputInterface::VERBOSITY_VERBOSE) {
             echo $client->getResponse();
         }
         return 1;
     }
 }
开发者ID:zeliard91,项目名称:orange-hotspot,代码行数:34,代码来源:CheckCommand.php

示例3: testNavigation

 /**
  * @dataProvider providerNavigation()
  */
 public function testNavigation($host, $paths)
 {
     $client = new Client();
     //Test with absolute path
     foreach ($paths as $path) {
         $uri = 'http://' . $host . $path;
         $crawler = $client->request('GET', $uri);
         $this->assertEquals(200, $client->getResponse()->getStatus());
         $this->assertEquals($uri, $client->getRequest()->getUri());
     }
     //Test with relative path and get absolute URI
     foreach ($paths as $path) {
         $uri = 'http://' . $host . $path;
         $crawler = $client->request('GET', $path);
         $this->assertEquals(200, $client->getResponse()->getStatus());
         $this->assertEquals($uri, $client->getRequest()->getUri());
     }
 }
开发者ID:gpupo,项目名称:camelspider,代码行数:21,代码来源:IndexerTest.php

示例4: dumpRawRequest

 /**
  * Dump latest raw request data
  *
  * @return string
  */
 public function dumpRawRequest()
 {
     return print_r($this->http_client->getRequest(), true);
 }
开发者ID:aakb,项目名称:bpi-client,代码行数:9,代码来源:Document.php

示例5: processPage

 protected function processPage($url)
 {
     try {
         $start = microtime(true);
         $client = new Client();
         $crawler = $client->request("GET", $url);
         $url = $this->regulateURL($client->getRequest()->getUri());
         //don't crawl HTTPS version of HTTP page
         $alt = '';
         $prot = $this->getProtocol($url);
         if ($prot === "https://") {
             $alt = preg_replace("/https:\\/\\//", "http://", $url);
         }
         if (!in_array($url, $this->traversed) && !in_array($alt, $this->traversed)) {
             array_push($this->traversed, $url);
             $statusCode = $client->getResponse()->getStatus();
             if ($statusCode == 200) {
                 //VALID URL
                 $page = array();
                 $page["url"] = $url;
                 $page["title"] = $this->getTitle($crawler, $url);
                 $page["metas"] = $this->getMetaTags($crawler, $url);
                 $page["h1s"] = $this->getH1s($crawler, $url);
                 $page["scripts"] = $this->getScripts($crawler, $url);
                 $page["stylesheets"] = $this->getStylesheets($crawler, $url);
                 // $page["keywords"] = $this->getKeywords($crawler, $url);
                 $page["links"] = $this->getLinks($crawler, $url);
                 $this->processor->process($page);
                 $end = microtime(true);
                 echo "Page indexed at [33m" . $url . "[0m in [36m" . number_format($end - $start, 2, ".", "") . " seconds[0m" . " with response code [32m200[0m" . PHP_EOL;
             } else {
                 echo "Page not indexed at [31m" . $url . "[0m due to status [31m" . $statusCode . "[0m" . PHP_EOL;
             }
         } else {
             // echo "Page ignored (already indexed) at \033[31m".$url."\033[0m".PHP_EOL;
         }
     } catch (\Guzzle\Http\Exception\CurlException $ex) {
     } catch (\Exception $ex) {
     }
 }
开发者ID:randak,项目名称:charlotte,代码行数:40,代码来源:Charlotte.php

示例6:

 $crawler = $client->request('GET', $url);
 $html = $crawler->html();
 $OUTPUT->togglePre("Show retrieved page", $html);
 $passed++;
 // Log in fail
 line_out("Looking for the form with a 'Log In' submit button");
 $form = $crawler->selectButton('Log In')->form();
 // var_dump($form->getPhpValues());
 line_out("Setting bad account and pw fields in the form");
 $form->setValues(array("account" => "bob", "pw" => "hellokitty"));
 $crawler = $client->submit($form);
 $passed++;
 $html = $crawler->html();
 $OUTPUT->togglePre("Show retrieved page", $html);
 line_out("Checking to see if there was a POST redirect to a GET");
 $method = $client->getRequest()->getMethod();
 if ($method == "get") {
     $passed++;
 } else {
     error_out('Expecting POST to Redirect to GET - found ' . $method);
 }
 line_out("Looking for a red 'Incorrect password' message");
 if (stripos($html, 'Incorrect password') !== false) {
     $passed++;
 } else {
     error_out("Could not find 'Incorrect password'");
 }
 // Log in correctly
 line_out("Setting the correct account and pw fields in the form");
 $form->setValues(array("account" => "bob", "pw" => "umsi"));
 $crawler = $client->submit($form);
开发者ID:ixtel,项目名称:tsugi,代码行数:31,代码来源:a05.php

示例7: get_uri_from_client

 /**
  * Get the requested uri from a Client object.
  *
  * @param Client $client
  * @return string
  */
 protected static function get_uri_from_client(Client $client)
 {
     return $client->getRequest()->getUri();
 }
开发者ID:kminh,项目名称:bwp-framework,代码行数:10,代码来源:wp-functional-testcase.php


注:本文中的Goutte\Client::getRequest方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。