コード例 #1
0
 public function handle($instance, $serverKey, $parameters, $httpRequestMethod)
 {
     // Validate HTTP Verb
     if (strtolower($httpRequestMethod) != "get") {
         throw new MashapeException(EXCEPTION_INVALID_HTTPMETHOD, EXCEPTION_INVALID_HTTPMETHOD_CODE);
     }
     // Validate request
     if ($this->validateRequest($serverKey) == false) {
         throw new MashapeException(EXCEPTION_AUTH_INVALID_SERVERKEY, EXCEPTION_AUTH_INVALID_SERVERKEY_CODE);
     }
     $resultXml = "<?xml version=\"1.0\" ?>\n";
     $fileParts = Explode('/', $_SERVER["PHP_SELF"]);
     $scriptName = $fileParts[count($fileParts) - 1];
     $baseUrl = Explode("/" . $scriptName, $this->curPageURL());
     $resultXml .= "<api baseUrl=\"" . $baseUrl[0] . "\" " . $this->getSimpleInfo() . ">\n";
     $mode = isset($parameters[MODE]) ? $parameters[MODE] : null;
     $configuration = RESTConfigurationLoader::reloadConfiguration($serverKey);
     if ($mode == null || $mode != SIMPLE_MODE) {
         $objectsFound = array();
         $objectsToCreate = array();
         $methods = discoverMethods($instance, $configuration, $objectsFound, $objectsToCreate, $scriptName);
         $objects = discoverObjects($configuration, $objectsFound);
         $resultXml .= $methods . $objects . generateObjects($objectsToCreate);
         // Update the .htaccess file with the new route settings
         updateHtaccess($instance);
     }
     $resultXml .= "</api>";
     return $resultXml;
 }
コード例 #2
0
ファイル: call.php プロジェクト: ATouhou/mashape-php-library
 private function reloadConfiguration($instance, $serverKey)
 {
     if (HttpUtils::isLocal()) {
         // Update the .htaccess file with the new route settings
         updateHtaccess($instance);
         // Update the configuration
         RESTConfigurationLoader::reloadConfiguration($serverKey);
     }
 }