本文整理汇总了PHP中REST::requireRequestMethod方法的典型用法代码示例。如果您正苦于以下问题:PHP REST::requireRequestMethod方法的具体用法?PHP REST::requireRequestMethod怎么用?PHP REST::requireRequestMethod使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类REST
的用法示例。
在下文中一共展示了REST::requireRequestMethod方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getEntities
public function getEntities()
{
REST::requireRequestMethod('GET');
$db = new MySQL();
$entitiesNode = new XMLNode('entities');
foreach (Model::getEntities() as $entity) {
$entityNode = new XMLNode('entity');
$entityNode->setAttribute('identifier', $entity['IDENTIFIER']);
$entityNode->setAttribute('friendlyname', $entity['FRIENDLYNAME']);
$entityNode->setAttribute('lat', $entity['LATITUDE']);
$entityNode->setAttribute('lon', $entity['LONGITUDE']);
$entityNode->setAttribute('date', strtotime($entity['DATETIME']));
$entitiesNode->addNode($entityNode);
}
$xmlDoc = new XMLDocument();
$xmlDoc->setRootNode($entitiesNode);
REST::sendResponse(200, $xmlDoc, 'application/xml');
}
示例2: getTileUrl
public function getTileUrl()
{
REST::requireRequestMethod('GET');
$requiredParameters = array('lat', 'lon', 'zoom');
if (Util::isValid($requiredParameters, $values, $this->params)) {
extract($values);
$url = "http://tile.openstreetmap.org/" . Map::getTileNumber($lat, $lon, $zoom) . ".png";
$urlNode = new XMLNode('url');
$urlNode->setAttribute('href', $url);
$mapNode = new XMLNode('map');
$mapNode->setAttributes($values);
$mapNode->addNode($urlNode);
$xmlDoc = new XMLDocument();
$xmlDoc->setRootNode($mapNode);
REST::sendResponse(200, $xmlDoc, 'application/xml');
} else {
REST::sendResponse(400);
}
}
示例3: getZones
public function getZones()
{
REST::requireRequestMethod('GET');
$zonesNode = new XMLNode('zones');
foreach (Model::getZones() as $zone) {
$zoneNode = new XMLNode('zone');
$zoneNode->setAttribute('id', $zone['ID']);
$zoneNode->setAttribute('type', $zone['TYPE']);
$zoneNode->setAttribute('date', strtotime($zone['CREATED_ON']));
$zoneNode->setAttribute('deleted', $zone['DELETED_ON'] != '0000-00-00 00:00:00' ? 'true' : 'false');
$waypointsNode = new XMLNode('waypoints');
foreach (Model::getWaypoints($zone['ID']) as $waypoint) {
$waypointNode = new XMLNode('waypoint');
$waypointNode->setAttribute('latitude', $waypoint['LATITUDE']);
$waypointNode->setAttribute('longitude', $waypoint['LONGITUDE']);
$waypointsNode->addNode($waypointNode);
}
$zoneNode->addNode($waypointsNode);
$zonesNode->addNode($zoneNode);
}
$xmlDoc = new XMLDocument();
$xmlDoc->setRootNode($zonesNode);
REST::sendResponse(200, $xmlDoc, 'application/xml');
}