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


PHP Client::setUri方法代碼示例

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


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

示例1: getResults

 /**
  * @return array
  */
 public function getResults($offset, $itemCountPerPage)
 {
     $query = $this->createSearchQuery($offset, $itemCountPerPage);
     $adapter = new Http\Client\Adapter\Curl();
     $adapter->setOptions(array('curloptions' => array(CURLOPT_SSL_VERIFYPEER => false)));
     $client = new Http\Client();
     $client->setAdapter($adapter);
     $client->setMethod('GET');
     $client->setUri($this->getOptions()->getSearchEndpoint() . $query);
     $response = $client->send();
     if (!$response->isSuccess()) {
         throw new Exception\RuntimeException("Invalid response received from CloudSearch.\n" . $response->getContent());
     }
     $results = Json::decode($response->getContent(), Json::TYPE_ARRAY);
     $this->count = $results['hits']['found'];
     if (0 == $this->count) {
         return array();
     }
     if ($this->getOptions()->getReturnIdResults()) {
         $results = $this->extractResultsToIdArray($results);
     }
     foreach ($this->getConverters() as $converter) {
         $results = $converter->convert($results);
     }
     return $results;
 }
開發者ID:outeredge,項目名稱:edge-zf2,代碼行數:29,代碼來源:CloudSearchSearcher.php

示例2: 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

示例3: fetchLinks

 /**
  * Fetch Links
  *
  * Fetches a set of links corresponding to an OpenURL
  *
  * @param string $openURL openURL (url-encoded)
  *
  * @return string         raw XML returned by resolver
  */
 public function fetchLinks($openURL)
 {
     // Make the call to SFX and load results
     $url = $this->baseUrl . '?sfx.response_type=multi_obj_detailed_xml&svc.fulltext=yes&' . $openURL;
     $feed = $this->httpClient->setUri($url)->send()->getBody();
     return $feed;
 }
開發者ID:bbeckman,項目名稱:NDL-VuFind2,代碼行數:16,代碼來源:Sfx.php

示例4: setRequestHandler

 /**
  * Sets request handler
  *
  * @param \Zend\Http\Client $handler
  * @return RemoteCompiler
  */
 public function setRequestHandler($handler)
 {
     $this->requestHandler = $handler;
     $this->requestHandler->setUri($this->url)->setMethod($this->method);
     $this->requestHandler->getUri()->setPort($this->port);
     return $this;
 }
開發者ID:neeckeloo,項目名稱:ClosureCompilerPHP,代碼行數:13,代碼來源:RemoteCompiler.php

示例5: updateAddressFormats

 /**
  * @param ProgressAdapter|null $progressAdapter
  */
 public function updateAddressFormats(ProgressAdapter $progressAdapter = null)
 {
     $localeDataUri = $this->options->getLocaleDataUri();
     $dataPath = $this->options->getDataPath();
     $locales = json_decode($this->httpClient->setUri($localeDataUri)->send()->getContent());
     foreach (scandir($dataPath) as $file) {
         if (fnmatch('*.json', $file)) {
             unlink($dataPath . '/' . $file);
         }
     }
     $countryCodes = isset($locales->countries) ? explode('~', $locales->countries) : [];
     $countryCodes[] = 'ZZ';
     if ($progressAdapter !== null) {
         $progressBar = new ProgressBar($progressAdapter, 0, count($countryCodes));
     }
     foreach ($countryCodes as $countryCode) {
         file_put_contents($dataPath . '/' . $countryCode . '.json', $this->httpClient->setUri($localeDataUri . '/' . $countryCode)->send()->getContent());
         if (isset($progressBar)) {
             $progressBar->next();
         }
     }
     if (isset($progressBar)) {
         $progressBar->finish();
     }
     // We clearly don't want the "ZZ" in the array!
     array_pop($countryCodes);
     $writer = new PhpArrayWriter();
     $writer->setUseBracketArraySyntax(true);
     $writer->toFile($this->options->getCountryCodesPath(), $countryCodes, false);
 }
開發者ID:DavidHavl,項目名稱:Ajasta,代碼行數:33,代碼來源:MaintenanceService.php

示例6: fetchLinks

 /**
  * Fetch Links
  *
  * Fetches a set of links corresponding to an OpenURL
  *
  * @param string $openURL openURL (url-encoded)
  *
  * @return string         raw XML returned by resolver
  */
 public function fetchLinks($openURL)
 {
     // Make the call to SerialsSolutions and load results
     $url = $this->baseUrl . (substr($this->baseUrl, -1) == '/' ? '' : '/') . 'openurlxml?version=1.0&' . $openURL;
     $feed = $this->httpClient->setUri($url)->send()->getBody();
     return $feed;
 }
開發者ID:tillk,項目名稱:vufind,代碼行數:16,代碼來源:Threesixtylink.php

示例7: __construct

 public function __construct($config)
 {
     if (!isset($config['yql_base_url'])) {
         throw new \InvalidArgumentException('Missing yql_base_url in config');
     }
     $this->client = new Client();
     $this->client->setUri($config['yql_base_url']);
     $this->client->setOptions(array('maxredirects' => 0, 'timeout' => 10));
 }
開發者ID:machek,項目名稱:mmyql,代碼行數:9,代碼來源:ServiceYQL.php

示例8: getContent

 /**
  * {@inheritDoc}
  */
 public function getContent($url)
 {
     try {
         $response = $this->client->setUri($url)->send();
         $content = $response->isSuccess() ? $response->getBody() : null;
     } catch (\Exception $e) {
         $content = null;
     }
     return $content;
 }
開發者ID:shopwings,項目名稱:Geocoder,代碼行數:13,代碼來源:ZendHttpAdapter.php

示例9: request

 /**
  * Call ja.is service and convert address to lat and lng
  *
  * @param string $address
  * @return object
  */
 public function request($address)
 {
     $response = $this->client->setUri("http://ja.is/kort/leit")->setMethod('GET')->setParameterGet(['q' => $address])->send();
     if ($response->getStatusCode() == 200) {
         $json = json_decode($response->getBody());
         return isset($json->items[0]->coordinates) ? (object) ['lat' => (double) $json->items[0]->coordinates->lat, 'lng' => (double) $json->items[0]->coordinates->lon] : (object) ['lat' => null, 'lng' => null];
     } else {
         return (object) ['lat' => null, 'lng' => null];
     }
 }
開發者ID:bix0r,項目名稱:Stjornvisi,代碼行數:16,代碼來源:JaMap.php

示例10: get

 /**
  * {@inheritDoc}
  */
 public function get($uri, array $headers = [])
 {
     $this->client->resetParameters();
     $this->client->setMethod('GET');
     $this->client->setHeaders(new Headers());
     $this->client->setUri($uri);
     if (!empty($headers)) {
         $this->injectHeaders($headers);
     }
     $response = $this->client->send();
     return new Response($response->getStatusCode(), $response->getBody(), $this->prepareResponseHeaders($response->getHeaders()));
 }
開發者ID:DenLilleMand,項目名稱:christianssite,代碼行數:15,代碼來源:ZendHttpClientDecorator.php

示例11: fetch

 /**
  * Fetch an image from either a URL or the cache (as appropriate).
  *
  * @param string $url URL to fetch
  *
  * @return Response
  */
 public function fetch($url)
 {
     $file = $this->getCacheFile($url);
     $cacheAllowed = $this->onWhitelist($url);
     if (!$cacheAllowed || !($response = $this->fetchCache($file))) {
         $response = $this->client->setUri($url)->send();
         if ($cacheAllowed) {
             $this->setCache($file, $response);
         }
     }
     return $response;
 }
開發者ID:datavoyager,項目名稱:vufind,代碼行數:19,代碼來源:CachingProxy.php

示例12: query

 public static function query($api, $command, $options = null)
 {
     // Validate configuration
     if (!self::getApiKey()) {
         throw new \Exception('Echonest has not been configured');
     }
     $http = new Client();
     $http->setUri(self::$source . $api . '/' . $command);
     $http->setOptions(array('sslverifypeer' => false));
     $http->setMethod('GET');
     $format = 'json';
     if (is_array($options)) {
         $http->setUri(self::$source . $api . '/' . $command);
         $options['api_key'] = self::getApiKey();
         if (!isset($options['format'])) {
             $options['format'] = $format;
         } else {
             $format = $options['format'];
         }
         // Build query manually as $http->setParameterGet builds arrays properly:
         // echonest api is not standard :/
         // We need ?bucket=audio_summary&bucket=artist_discovery NOT ?bucket[0]=audio_summary&bucket[1]=artist_discovery
         //strip array indexes
         $http_query = preg_replace('/%5B[0-9]+%5D/simU', '', http_build_query($options));
         $http->setUri(self::$source . $api . '/' . $command . '?' . $http_query);
     } else {
         #options as a query string
         if (!$options) {
             throw new \Exception("The options must be an array or a non empty string");
         }
         if (!strpos($options, 'api_key')) {
             $options .= '&api_key=' . self::getApiKey();
         }
         #find format in query string
         preg_match('/format=([^&]+)&/', $options, $matches);
         if (is_array($matches)) {
             $format = $matches[1] ? $matches[1] : 'json';
         }
         $http->setUri(self::$source . $api . '/' . $command . '?' . $options);
     }
     $response = $http->send();
     #output response according to format
     if ($format == 'xml') {
         return simplexml_load_string($response->getBody());
     } else {
         return Json::decode($response->getBody());
     }
 }
開發者ID:MusicalAPP,項目名稱:EchonestClient-PHP,代碼行數:48,代碼來源:Echonest.php

示例13: pesquisaCep

 public function pesquisaCep($strCEP)
 {
     $httpClient = new Client();
     $httpClient->setUri('http://webservice.kinghost.net/web_cep.php')->setParameterGet(array('auth' => $this->auth, 'formato' => 'json', 'cep' => $strCEP));
     $response = (object) json_decode($httpClient->send()->getBody(), true);
     return array('uf' => $response->uf, 'cidade' => $response->cidade, 'bairro' => $response->bairro, 'logradouro' => $response->logradouro, 'status' => $response->resultado ? true : false, 'message' => !$response->resultado ? 'CEP não encontrado' : '');
 }
開發者ID:ualisonaguiar,項目名稱:shome2,代碼行數:7,代碼來源:KingHost.php

示例14: send

 /**
  * @param MessageInterface|Message $message
  * @return mixed|void
  * @throws RuntimeException
  */
 public function send(MessageInterface $message)
 {
     $config = $this->getSenderOptions();
     $serviceURL = "http://letsads.com/api";
     $body = new \SimpleXMLElement('<?xml version="1.0" encoding="UTF-8"?><request></request>');
     $auth = $body->addChild('auth');
     $auth->addChild('login', $config->getUsername());
     $auth->addChild('password', $config->getPassword());
     $messageXML = $body->addChild('message');
     $messageXML->addChild('from', $config->getSender());
     $messageXML->addChild('text', $message->getMessage());
     $messageXML->addChild('recipient', $message->getRecipient());
     $client = new Client();
     $client->setMethod(Request::METHOD_POST);
     $client->setUri($serviceURL);
     $client->setRawBody($body->asXML());
     $client->setOptions(['sslverifypeer' => false, 'sslallowselfsigned' => true]);
     try {
         $response = $client->send();
     } catch (Client\Exception\RuntimeException $e) {
         throw new RuntimeException("Failed to send sms", null, $e);
     }
     try {
         $responseXML = new \SimpleXMLElement($response->getBody());
     } catch (\Exception $e) {
         throw new RuntimeException("Cannot parse response", null, $e);
     }
     if ($responseXML->name === 'error') {
         throw new RuntimeException("LetsAds return error (" . $responseXML->description . ')');
     }
 }
開發者ID:andreylis,項目名稱:zf2-sms-adapters,代碼行數:36,代碼來源:LetsAdsAdapter.php

示例15: validate

 /**
  * @return CasResult
  */
 public function validate()
 {
     try {
         $uri = $this->createValidateUri();
     } catch (Adapter\Exception\InvalidArgumentException $e) {
         return new CasResult(CasResult::FAILURE, '', array($e->getMessage()));
     }
     $this->httpClient->resetParameters();
     $this->httpClient->setUri($uri);
     try {
         $response = $this->httpClient->send();
     } catch (Http\Exception\RuntimeException $e) {
         return new CasResult(CasResult::FAILURE_UNCATEGORIZED, '', array($e->getMessage()));
     }
     if (!$response->isSuccess()) {
         return new CasResult(CasResult::FAILURE_UNCATEGORIZED, '', array('HTTP response did not indicate success.'), $response->getBody());
     }
     $body = $response->getBody();
     $explodedResponse = explode("\n", $body);
     if (count($explodedResponse) < 2) {
         return new CasResult(CasResult::FAILURE_UNCATEGORIZED, '', array('Got an invalid CAS 1.0 response.'), $body);
     }
     $status = $explodedResponse[0];
     $identity = $explodedResponse[1];
     if ($status !== 'yes') {
         return new CasResult(CasResult::FAILURE_UNCATEGORIZED, '', array('Authentication failed.'), $body);
     }
     return new CasResult(CasResult::SUCCESS, $identity, array(), $body);
 }
開發者ID:tillikum,項目名稱:zf2-cas-authentication-adapter,代碼行數:32,代碼來源:Cas.php


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