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


PHP HttpRequest::responseText方法代码示例

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


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

示例1: discover

 /**
  * Examine the URL, optionally looking for a specific service. If no
  * service selection is done, all the services that the URL publishes
  * will be returned.
  *
  * @param string $url The URL to explore
  * @param string $service The service to look for
  * @return array An array of the exposed services at the URL
  */
 function discover($url, $services = null)
 {
     // Perform the query
     $ret = new HttpRequest($url);
     // Grab the data
     $status = $ret->status();
     $content = $ret->responseText();
     $headers = $ret->headers();
     $results = array();
     // Enumerate the explorers
     $explorers = config::get(Discovery::KEY_EXPLORERS, array());
     foreach ($explorers as $explorer) {
         // Discover the service and merge the results
         $instance = new $explorer($url, $headers, $content);
         $instance->discover();
         if ($services) {
             foreach ($instance->getAllServices() as $stype => $sdata) {
                 // Return the service if it matches the type.
                 if ($stype == $service) {
                     return $sdata;
                 }
             }
         } else {
             // Merge the resultset otherwise
             $results = array_merge($results, $instance->getAllServices());
         }
     }
     // Return null if we were looking for a specific service
     if ($services) {
         return null;
     }
     return $results;
 }
开发者ID:noccy80,项目名称:lepton-ng,代码行数:42,代码来源:discovery.php

示例2: translate

 function translate($string)
 {
     switch ($this->apiversion) {
         case 1:
             $langs = join('|', array($this->fromlang, $this->tolang));
             $translation = array();
             $url = 'http://ajax.googleapis.com/ajax/services/language/translate';
             $r = new HttpRequest($url, array('parameters' => array('v' => '1.0', 'q' => $string, 'langpair' => $langs)));
             $rd = json_decode($r->responseText(), true);
             $rstr = $rd['responseData']['translatedText'];
             break;
         case 2:
         default:
             throw new BaseException("GoogleTranslate API Version 2 not implemented");
             $rstr = $string;
             break;
     }
     return $rstr;
 }
开发者ID:noccy80,项目名称:lepton-ng,代码行数:19,代码来源:translate.php

示例3: call

 /**
  * Call a method on the server. The result is returned decoded as
  * native PHP data.
  *
  * @param string $method The method to call
  * @param any $data The data
  * @return any The result data
  */
 function call($method, $args = null)
 {
     logger::debug("Sending XmlrpcRequest to %s ...", $method);
     $req = xmlrpc_encode_request($method, $args);
     logger::debug('%s', $req);
     $opts = array('method' => 'post', 'parameters' => $req, 'content-type' => 'text/xml');
     if ($this->username) {
         $opts['username'] = $this->username;
         $opts['password'] = $this->password;
     }
     $opts = array_merge($opts, $this->httpopts);
     $ret = new HttpRequest($this->url, $opts);
     logger::debug('Response: %s', $ret->responseText());
     $mtd = null;
     $dec = xmlrpc_decode_request($ret->responseText(), $mtd);
     /*
          if ($dec && arr::hasKey($dec,'faultCode')) {
          	printf("Fault\n");
          }
     */
     return $dec;
     /*
         // Encode the request
         $xml = xmlrpc_encode_request( $method, $args );
     
         // Send it to the server
         $sparams = array('http' => array(
             'method' => 'POST',
             'content' => $xml,
             'header' => array(
                 'content-type' => 'text/xml'
             )
         ));
         $ctx = stream_context_create($params);
         $fp = @fopen($this->url, 'rb', false, $ctx);
         if (!$fp) {
             throw new Exception("Problem with $this->url, $php_errormsg");
         }
         $response = @stream_get_contents($fp);
         if ($response === false) {
             throw new Exception("Problem reading data from $url, $php_errormsg");
         }
     
         // Parse the output
         $ret = xmlrpc_decode_request($response,$mtd);
         return $ret;
     */
 }
开发者ID:noccy80,项目名称:lepton-ng,代码行数:56,代码来源:xmlrpc.php

示例4: __construct

 /**
  * @brief Constructor for Password Authentication
  *
  * @param string $username The username for which to validate the token
  * @param string $password The user's password.
  */
 public function __construct()
 {
     $token = request::get('token')->toString();
     $apikey = config::get('lepton.user.engage.apikey');
     $ret = new HttpRequest('https://rpxnow.com/api/v2/auth_info', array('method' => 'post', 'parameters' => array('apiKey' => $apikey, 'token' => $token, 'format' => 'xml')));
     $dom = DOMDocument::loadXml($ret->responseText());
     $domx = new DOMXPath($dom);
     // Get the status
     $status = $domx->query('/rsp')->item(0)->getAttribute('stat');
     if ($status == 'ok') {
         // Call on the successful callback method
         event::invoke(EngageEvents::EVENT_SUCCESSFUL_CALLBACK, array('profile' => $dom, 'profiletext' => $ret->responseText()));
         // Extract the values
         $identifier = $domx->query('/rsp/profile/identifier')->item(0)->nodeValue;
         $displayname = $domx->query('/rsp/profile/displayName')->item(0)->nodeValue;
         $provider = $domx->query('/rsp/profile/providerName')->item(0)->nodeValue;
         $firstname = $domx->query('/rsp/profile/name/givenName')->item(0)->nodeValue;
         $lastname = $domx->query('/rsp/profile/name/familyName')->item(0)->nodeValue;
         $preferredusername = $domx->query('/rsp/profile/preferredUsername')->item(0)->nodeValue;
         $email = $domx->query('/rsp/profile/email')->item(0)->nodeValue;
         // Sign in
         $db = new DatabaseConnection();
         $idrs = $db->getSingleRow("SELECT * FROM userengage WHERE identifier=%s", $identifier);
         if ($idrs) {
             $cu = $idrs['userid'];
             $db->updateRow("UPDATE userengage SET lastseen=NOW(), lastip=%s WHERE id=%d", request::getRemoteIp(), $idrs['id']);
         } else {
             if (!user::isAuthenticated()) {
                 if (!config::get(EngageAuthentication::KEY_ALLOW_CREATION, false)) {
                     throw new SecurityException("User creation is disabled for EngageAuthentication");
                 }
                 // Check username, add random numbers if not available
                 $username = $preferredusername;
                 $retrycount = 0;
                 while (!user::checkUsername($username)) {
                     $username = substr($preferredusername, 0, 6) . rand(1000, 9999);
                     $retrycount = $retrycount + 1;
                     if ($retrycount > 10) {
                         throw new UserException("Bad username");
                     }
                 }
                 // Generate a new password
                 $password = substr(md5(uniqid()), 0, 6);
                 // And create the userrecord
                 $u = new UserRecord();
                 $u->username = $username;
                 $u->password = $password;
                 $u->flags = config::get(EngageAuthentication::KEY_DEFAULT_FLAGS, EngageAuthentication::DEFAULT_FLAGS);
                 $u->displayname = $displayname;
                 $u->firstname = $firstname;
                 $u->lastname = $lastname;
                 $u->email = $email;
                 $cu = user::create($u);
                 session::set(self::SESSIONKEY_USER_CREATED, true);
             } else {
                 $cu = user::getActiveUser();
             }
             // Add identifier to user
             $db->updateRow("INSERT INTO userengage (userid,identifier,provider,lastseen,lastip) VALUES (%d,%s,%s,NOW(),%s)", $cu, $identifier, $provider, request::getRemoteIp());
         }
         $this->userid = $cu;
     } else {
         $this->userid = null;
     }
 }
开发者ID:noccy80,项目名称:lepton-ng,代码行数:71,代码来源:engage.php


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