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


PHP HttpResponse::getResponseText方法代码示例

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


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

示例1: Test

 /** Test Wookie server connection
  *  @return boolean true if success, otherwise false
  */
 public function Test()
 {
     $ctx = @stream_context_create(array('http' => array('timeout' => 15)));
     $url = $this->getURL();
     if (!empty($url)) {
         $response = new HttpResponse(@file_get_contents($url . 'advertise?all=true', false, $ctx), $http_response_header);
         if ($response->getStatusCode() == 200) {
             $xmlDoc = @simplexml_load_string($response->getResponseText());
             if (is_object($xmlDoc) && $xmlDoc->getName() == 'widgets') {
                 return true;
             }
         }
     }
     return false;
 }
开发者ID:rommsen,项目名称:plesynd,代码行数:18,代码来源:WookieServerConnection.php

示例2: getProperty

 /**
  * Get property for Widget instance
  * @param WidgetInstance instance of WidgetInstance
  * @param Propety instance of WidgetProperty
  * @return WidgetProperty if request fails, return false;
  * @throws WookieConnectorException, WookieWidgetInstanceException
  */
 public function getProperty($widgetInstance, $propertyInstance)
 {
     $Url = $this->getConnection()->getURL() . 'properties';
     try {
         if (!$widgetInstance instanceof WidgetInstance) {
             throw new Exception\WookieWidgetInstanceException('No Widget instance');
         }
         if (!$propertyInstance instanceof WidgetProperty) {
             throw new Exception\WookieConnectorException('No properties instance');
         }
         $data = array('api_key' => $this->getConnection()->getApiKey(), 'shareddatakey' => $this->getConnection()->getSharedDataKey(), 'userid' => $this->getUser()->getLoginName(), 'widgetid' => $widgetInstance->getIdentifier(), 'propertyname' => $propertyInstance->getName());
         $request = @http_build_query($data);
         if (!$this->checkURL($Url)) {
             throw new Exception\WookieConnectorException("Properties rest URL is incorrect: " . $Url);
         }
         $response = new HttpResponse(@file_get_contents($Url . '?' . $request, false, $this->getHttpStreamContext()), $http_response_header);
         $statusCode = $response->getStatusCode();
         if ($statusCode != 200) {
             throw new Exception\WookieConnectorException($response->headerToString() . '<br />' . $response->getResponseText());
         }
         return new WidgetProperty($propertyInstance->getName(), $response->getResponseText());
     } catch (WookieConnectorException $e) {
         $this->getLogger()->write($e->toString());
     } catch (WookieWidgetInstanceException $e) {
         $this->getLogger()->write($e->toString());
     }
     return false;
 }
开发者ID:rommsen,项目名称:plesynd,代码行数:35,代码来源:WookieConnectorService.php


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