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


PHP phpCAS::getProxiedService方法代碼示例

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


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

示例1: retrieveData

 /**
  * Retrieves the data using the given url. The default implementation uses the file_get_content()
  * function to retrieve the request. Subclasses would need to implement this if a simple GET request
  * is not sufficient (i.e. you need POST or custom headers). 
  * @param string the url to retrieve
  * @return string the response from the server
  * @TODO support POST requests and custom headers and perhaps proxy requests
  */
 protected function retrieveData($url)
 {
     if ($this->debugMode) {
         error_log(sprintf(__CLASS__ . " Retrieving %s", $url));
     }
     try {
         if ($this->method == 'GET') {
             $http = phpCAS::getProxiedService(PHPCAS_PROXIED_SERVICE_HTTP_GET);
         } else {
             if ($this->method = 'POST') {
                 $http = phpCAS::getProxiedService(PHPCAS_PROXIED_SERVICE_HTTP_POST);
             } else {
                 throw new Exception('Unsupported HTTP method ' . $this->method);
             }
         }
         $http->setUrl($url);
         // Not yet supported in phpCAS-1.2.2, will be added in a future version.
         //      foreach ($this->getHeaders() as $header) {
         //          $http->addRequestHeader($header);
         //      }
         $http->send();
         $this->response = DataResponse::factory('HTTPDataResponse', array());
         $this->response->setRequest($this->method, $url, $this->filters, $this->requestHeaders);
         $this->response->setResponse($http->getResponseBody(), $http->getResponseHeaders());
         if ($this->debugMode) {
             error_log(sprintf(__CLASS__ . " Returned status %d and %d bytes", $this->getResponseCode(), strlen($data)));
         }
         return $http->getResponseBody();
     } catch (CAS_ProxyTicketException $e) {
         if ($this->debugMode) {
             error_log(__CLASS__ . " The user's proxy ticket expired, prompt for login.");
         }
         // For now we will just re-throw the exception and let the WebModule that
         // is calling us handle prompting for re-authentication.
         throw $e;
     }
 }
開發者ID:nncsang,項目名稱:Kurogo,代碼行數:45,代碼來源:CASProxyAuthenticatedDataController.php

示例2: flush

    <?php 
require 'script_info.php';
?>
    <p>the user's login is <b><?php 
echo phpCAS::getUser();
?>
</b>.</p>
    <h2>Response from service <?php 
echo $serviceUrl;
?>
</h2>
<?php 
flush();
// call a service and change the color depending on the result
try {
    $service = phpCAS::getProxiedService(PHPCAS_PROXIED_SERVICE_HTTP_POST);
    $service->setUrl($serviceUrl);
    $service->setContentType('application/x-www-form-urlencoded');
    $service->setBody('favorite_color=blue');
    $service->send();
    if ($service->getResponseStatusCode() == 200) {
        echo '<div class="success">';
        echo $service->getResponseBody();
        echo '</div>';
    } else {
        // The service responded with an error code 404, 500, etc.
        echo '<div class="error">';
        echo 'The service responded with a ' . $service->getResponseStatusCode() . ' error.';
        echo $service->getResponseBody();
        echo '</div>';
    }
開發者ID:TexGG,項目名稱:Libertempo,代碼行數:31,代碼來源:example_proxy_POST.php


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