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


PHP Client::getRequest方法代码示例

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


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

示例1: __construct

 /**
  * @param HttpClient $httpClient
  * @param HttpRequest $httpRequest
  * @param ModuleOptions $moduleOptions
  */
 public function __construct(HttpClient $httpClient, HttpRequest $httpRequest, ModuleOptions $moduleOptions)
 {
     $this->httpClient = $httpClient;
     $this->httpRequest = $httpRequest;
     $this->moduleOptions = $moduleOptions;
     $this->httpClient->getRequest()->getHeaders()->addHeaders(array('Accept' => 'application/json'));
 }
开发者ID:spalax,项目名称:eu-webchalange-download-images-api,代码行数:12,代码来源:Client.php

示例2: getHttpClient

 /**
  * Return the singleton instance of the HTTP Client. Note that
  * the instance is reset and cleared of previous parameters and
  * Authorization header values.
  *
  * @return Zend\Http\Client
  */
 public static function getHttpClient()
 {
     if (!isset(self::$httpClient)) {
         self::$httpClient = new HTTPClient();
     } else {
         $request = self::$httpClient->getRequest();
         $headers = $request->getHeaders();
         if ($headers->has('Authorization')) {
             $auth = $headers->get('Authorization');
             $headers->removeHeader($auth);
         }
         self::$httpClient->resetParameters();
     }
     return self::$httpClient;
 }
开发者ID:binary-data,项目名称:ZendOAuth,代码行数:22,代码来源:OAuth.php

示例3: getClientUrl

 protected function getClientUrl(Client $client)
 {
     $uri = $client->getUri();
     $query = $client->getRequest()->getQuery()->toString();
     //$post = $client->getRequest()->getPost()->toString();
     return $uri . '?' . $query;
 }
开发者ID:belgattitude,项目名称:openstore-client,代码行数:7,代码来源:BaseService.php

示例4: setPostRut

 function setPostRut($ruts)
 {
     foreach ($ruts as $rut) {
         $busqueda[] = explode('-', $rut[0]);
     }
     echo '<pre>';
     print_r($busqueda);
     echo '</pre>';
     $client = new Client('http://reca.poderjudicial.cl/', array('maxredirects' => 100, 'timeout' => 600, 'keepalive' => true));
     $headers = $client->getRequest()->getHeaders();
     $cookies = new Zend\Http\Cookies($headers);
     $client->setMethod('GET');
     $response = $client->send();
     $client->setUri('http://reca.poderjudicial.cl/RECAWEB/AtPublicoViewAccion.do?tipoMenuATP=1');
     $cookies->addCookiesFromResponse($response, $client->getUri());
     $response = $client->send();
     $client->setUri("http://reca.poderjudicial.cl/RECAWEB/AtPublicoDAction.do");
     foreach ($busqueda as $rut) {
         $parametros = array('actionViewBusqueda' => '2', 'FLG_Busqueda' => '2', 'FLG_User_Valid' => '0', 'TIP_Lengueta' => 'tdDos', 'COD_Competencia' => 'C', 'tribunal_aux' => '-1', 'username_aux' => '', 'password_aux' => '', 'aux_codlibro' => '', 'aux_rolinterno' => '', 'aux_eracausa' => '', 'aux_codcorte' => '', 'RUT_Cod_Competencia' => 'C', 'RUT_Rut' => $rut[0], 'RUT_Rut_Db' => $rut[1], 'RIT_Cod_Competencia' => '0', 'RIT_Tip_Causa' => '0', 'RIT_Rol_Interno' => '', 'RIT_Era_Causa' => '', 'corte_Cod_Tribunal' => '-1', 'corte_Cod_Libro' => '0', 'corte_Rol_Interno' => '', 'corte_Era_Causa' => '', 'OPC_Cod_Corte' => '-1', 'OPC_Cod_Tribunal' => '-1', 'username' => '', 'password' => '');
         $client->setParameterPost($parametros);
         echo '<pre>';
         print_r($parametros);
         echo '</pre>';
         $response = $client->setMethod('POST')->send();
         $data = $response->getContent();
         echo '<pre>';
         print_r($response->getContent());
         echo '</pre>';
         die;
         $rut = $rut[0] . '-' . $rut[1];
         $dom = new Query($data);
         $resultados = $dom->execute('#divRecursos tr');
         $rols = $this->busquedaRut($resultados, $rut);
     }
 }
开发者ID:jpablocasanueva,项目名称:pjud_v1,代码行数:35,代码来源:busquedaRut.php

示例5: injectHeaders

 /**
  * Inject header values into the client.
  *
  * @param array $headerValues
  */
 private function injectHeaders(array $headerValues)
 {
     $headers = $this->client->getRequest()->getHeaders();
     foreach ($headerValues as $name => $values) {
         if (!is_string($name) || is_numeric($name) || empty($name)) {
             throw new Exception\InvalidArgumentException(sprintf('Header names provided to %s::get must be non-empty, non-numeric strings; received %s', __CLASS__, $name));
         }
         if (!is_array($values)) {
             throw new Exception\InvalidArgumentException(sprintf('Header values provided to %s::get must be arrays of values; received %s', __CLASS__, is_object($values) ? get_class($values) : gettype($values)));
         }
         foreach ($values as $value) {
             if (!is_string($value) && !is_numeric($value)) {
                 throw new Exception\InvalidArgumentException(sprintf('Individual header values provided to %s::get must be strings or numbers; ' . 'received %s for header %s', __CLASS__, is_object($value) ? get_class($value) : gettype($value), $name));
             }
             $headers->addHeaderLine($name, $value);
         }
     }
 }
开发者ID:DenLilleMand,项目名称:christianssite,代码行数:23,代码来源:ZendHttpClientDecorator.php

示例6: connect

 public function connect($uri, $post = false, $params = null)
 {
     $client = new Client($uri, array('timeout' => 600, 'sslverifypeer' => false));
     if (!$post) {
         $client->setParameterGet($params);
     }
     $request = $client->getRequest();
     $response = $client->dispatch($request);
     return $response;
 }
开发者ID:ksr10,项目名称:bw,代码行数:10,代码来源:Connect.php

示例7: testPostDataUrlEncoded

 /**
  * Test we can properly send POST parameters with
  * application/x-www-form-urlencoded content type
  *
  * @dataProvider parameterArrayProvider
  */
 public function testPostDataUrlEncoded($params)
 {
     $this->client->setUri($this->baseuri . 'testPostData.php');
     $this->client->setEncType(HTTPClient::ENC_URLENCODED);
     $this->client->setParameterPost($params);
     $this->client->setMethod('POST');
     $this->assertFalse($this->client->getRequest()->isPatch());
     $res = $this->client->send();
     $this->assertEquals(serialize($params), $res->getBody(), "POST data integrity test failed");
 }
开发者ID:navassouza,项目名称:zf2,代码行数:16,代码来源:CommonHttpTests.php

示例8: getRequest

 /**
  * Get Request
  *
  * @return Request
  */
 public function getRequest()
 {
     if (empty($this->request)) {
         $headers = new Headers();
         $headers->addHeaders(array('Accept' => 'application/json', 'Content-Type' => 'application/json'));
         $request = parent::getRequest();
         $request->setHeaders($headers);
         $request->setMethod('POST');
     }
     return $this->request;
 }
开发者ID:webpants,项目名称:YAWIK,代码行数:16,代码来源:RestClient.php

示例9: createService

 public function createService(ServiceLocatorInterface $serviceLocator)
 {
     $config = $serviceLocator->get('Config');
     $client = new Client();
     $client->setOptions($config['oauth2']['httpClient']);
     $token = $serviceLocator->get('OAuth2\\Token');
     if ($token->isValid()) {
         $client->getRequest()->getHeaders()->addHeaderLine('Authorization', "{$token->getTokenType()} {$token->getAccessToken()}");
     }
     return $client;
 }
开发者ID:coogle,项目名称:oauth2,代码行数:11,代码来源:ClientFactory.php

示例10: renderTemplate

 /**
  * @return string
  */
 public function renderTemplate()
 {
     $config = $this->getServiceLocator()->get('Config');
     if (!isset($config['wordpress']['template'])) {
         throw new Exception\InvalidServiceException('No wordpress template defined');
     }
     $client = new Client($config['wordpress']['template']);
     $client->setAdapter(new Client\Adapter\Curl());
     $client->setMethod('GET');
     $response = $client->send($client->getRequest());
     return $response->getBody();
 }
开发者ID:PoetikDragon,项目名称:USCSS,代码行数:15,代码来源:WordpressService.php

示例11: send

 /**
  * @param \SMS\Model\Number $from
  * @param \SMS\Model\Number $to
  * @param \SMS\Model\Content $content
  * @return bool
  * @throws \SMS\SMSException
  * @throws \Exception
  */
 public function send(Number $from, Number $to, Content $content)
 {
     $client = new Client();
     $client->setUri($this->prepareUrl($from, $to, $content));
     $client->setMethod('GET');
     $client->setOptions(array('ssltransport' => 'tls', 'sslverify_peer' => false, 'sslcapath' => '/etc/ssl/certs'));
     $response = $client->send($client->getRequest());
     $responsejson = json_decode($response->getContent());
     if ($responsejson->status != 100) {
         throw new SMSException($response);
     }
     return true;
 }
开发者ID:Primetron,项目名称:Edusoft,代码行数:21,代码来源:OVHAPI.php

示例12: sendRequest

 /**
  * Perform a single OAI-PMH request.
  *
  * @param string $verb   OAI-PMH verb to execute.
  * @param array  $params GET parameters for ListRecords method.
  *
  * @return string
  */
 protected function sendRequest($verb, $params)
 {
     // Set up the request:
     $this->client->resetParameters();
     $this->client->setUri($this->baseUrl);
     // Load request parameters:
     $query = $this->client->getRequest()->getQuery();
     $query->set('verb', $verb);
     foreach ($params as $key => $value) {
         $query->set($key, $value);
     }
     // Perform request:
     return $this->client->setMethod('GET')->send();
 }
开发者ID:vufind-org,项目名称:vufindharvest,代码行数:22,代码来源:Communicator.php

示例13: execute

 public function execute()
 {
     $payload = $this->getContent();
     echo "processing >> " . $payload['page_url'] . " >> for id >> " . $payload['page_id'] . "\n";
     /* @var \Application\V1\Entity\Pages $pageEntity */
     $pageEntity = $this->entityManager->find('Application\\V1\\Entity\\Pages', $payload['page_id']);
     try {
         $this->httpClient->setUri($payload['page_url']);
         $response = $this->httpClient->send();
         $document = new Document($response->getBody());
         $manager = $this->grabImageQueue->getJobPluginManager();
         $jobs = [];
         $parsedPageUrl = parse_url($this->httpClient->getRequest()->getUriString());
         $cnt = 0;
         /* @var \DOMElement $node */
         foreach ($this->documentQuery->execute('//body//img', $document) as $node) {
             $job = $manager->get('Application\\QueueJob\\GrabImage');
             $src = $this->normalizeSchemeAndHost($node->getAttribute('src'), $parsedPageUrl['scheme'], $parsedPageUrl['host']);
             $ext = strtolower(pathinfo($src, PATHINFO_EXTENSION));
             $job->setContent(['image_src' => $src, 'image_ext' => $ext, 'page_id' => $payload['page_id']]);
             $jobs[] = $job;
             $cnt++;
         }
         if ($cnt < 1) {
             $pageEntity->setStatus(PageInterface::STATUS_DONE);
         } else {
             $pageEntity->setStatus(PageInterface::STATUS_RUNNING);
         }
         $pageEntity->setPendingImagesCnt($cnt);
         $pageEntity->setTotalImagesCnt($cnt);
         $this->entityManager->flush();
         foreach ($jobs as $job) {
             $this->grabImageQueue->push($job);
         }
         echo "Jobs to push >> " . count($jobs) . " count pending images >>" . $cnt . "\n";
     } catch (\Exception $e) {
         echo 'Exception: >> ' . $e->getMessage();
         $pageEntity->setErrorMessage($e->getMessage());
         if ($pageEntity->getStatusNumeric() == PageInterface::STATUS_RECOVERING) {
             $pageEntity->setStatus(PageInterface::STATUS_ERROR);
             $this->entityManager->flush();
             return WorkerEvent::JOB_STATUS_FAILURE;
         } else {
             $pageEntity->setStatus(PageInterface::STATUS_RECOVERING);
             $this->entityManager->flush();
             throw new ReleasableException(array('priority' => 10, 'delay' => 15));
         }
     }
 }
开发者ID:spalax,项目名称:eu-webchalange-download-images-api,代码行数:49,代码来源:ParsePage.php

示例14: run

 public static function run(Service\ServiceAbstract $service)
 {
     $request = new Request();
     $client = new Client();
     $adapter = new Adapter\Curl();
     $request->setMethod('GET');
     $client->setAdapter($adapter);
     foreach ($service as $url) {
         if (!is_string($url)) {
             continue;
         }
         $client->setUri($url);
         $response = $client->send($client->getRequest());
         echo $url . " --> " . $response->getStatusCode();
     }
 }
开发者ID:sullenboom,项目名称:sla-healthcheck,代码行数:16,代码来源:Java.php

示例15: githubContributorsAction

 public function githubContributorsAction()
 {
     $this->verifyConsole();
     $width = $this->console->getWidth();
     $this->console->writeLine('Fetching GitHub Contributors', Color::GREEN);
     $client = new HttpClient();
     $client->setAdapter('Zend\\Http\\Client\\Adapter\\Curl');
     $client->setUri('https://api.github.com/repos/zendframework/zf2/contributors');
     if (isset($this->config['github_token']) && $this->config['github_token']) {
         $httpRequest = $client->getRequest();
         $httpRequest->getHeaders()->addHeaderLine('Authorization', 'token ' . $this->config['github_token']);
     }
     $response = $client->send();
     if (!$response->isSuccess()) {
         // report failure
         $message = $response->getStatusCode() . ': ' . $response->getReasonPhrase();
         $this->reportError($width, 0, $message);
         return;
     }
     $body = $response->getBody();
     $contributors = json_decode($body, true);
     $total = count($contributors);
     foreach ($contributors as $i => $contributor) {
         $message = sprintf('    Processing %d/%d', $i, $total);
         $this->console->write($message);
         $client->setUri("https://api.github.com/users/{$contributor['login']}");
         $response = $client->send();
         if (!$response->isSuccess()) {
             // report failure
             $error = $response->getStatusCode() . ': ' . $response->getReasonPhrase();
             $this->reportError($width, strlen($message), $error);
         }
         $body = $response->getBody();
         $userInfo = json_decode($body, 1);
         $contributors[$i]['user_info'] = $userInfo;
         $this->reportSuccess($width, strlen($message));
     }
     $this->console->writeLine(str_repeat('-', $width));
     $message = 'Writing file';
     $this->console->write($message, Color::BLUE);
     // file_put_contents(__DIR__ . '/../../../data/contributors/contributors.pson', serialize($contributors));
     $path = $this->config['github-contributors']['output_file'];
     file_put_contents($path, serialize($contributors));
     $this->reportSuccess($width, strlen($message));
     $this->console->writeLine(sprintf('File written to %s', $path));
 }
开发者ID:Tony133,项目名称:zf-web,代码行数:46,代码来源:ConsoleController.php


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