本文整理汇总了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;
}
示例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;
}