Beispiel #1
0
 private function _save_feed($feed_url, $feed_category, $updatePeriod, $weight)
 {
     if (isset($feed_url) && !empty($feed_url) && $feed_url != '' && $feed_category > 0) {
         $json = '{"type":"RSS",' . '"updatePeriod":"' . $updatePeriod . '",' . '"parameters":{' . '"feedUrl":"' . $feed_url . '"' . '}}';
         $coreFolder = DOCROOT . "/../Core/";
         $coreSetupFile = $coreFolder . "Setup.php";
         include_once $coreSetupFile;
         $workflow = new Swiftriver\Core\Workflows\ChannelProcessingJobs\RegisterNewProcessingJob();
         $workflow->RunWorkflow($json, "swiftriver_apala");
         /* APALA - Dropped in favor of file call
            $service = new ServiceWrapper($this->API_URL."RegisterNewProcessingJob.php");
            $service->MakePOSTRequest(array("key" => "test", "data" => $json), 5);
            */
     }
 }
<?php

namespace Swiftriver\Core\ServiceAPI\ChannelProcessingJobServices;

header('Content-type: application/json');
//Check for the existance of the unique Swift instance Key
if (!isset($_POST["key"])) {
    //If not found then return a JSON error
    echo '{"error":"The request to this service did not contain the required post data \'key\'"}';
    die;
} elseif (!isset($_POST["data"])) {
    //if not present then return a JSON error
    echo '{"error":"The request to this service did not contain the required post data \'data\'"}';
    die;
} else {
    //include the setup file
    include_once dirname(__FILE__) . "/../../Setup.php";
    //create a new workflow instance
    $workflow = new \Swiftriver\Core\Workflows\ChannelProcessingJobs\RegisterNewProcessingJob();
    //Check that the key supplied works with this core instance
    if (!$workflow->CheckKey($_POST["key"])) {
        //If not then return an error in JSON
        echo '{"error":"The key you supplied is not registered with this instance of the Swiftriver Core"}';
        die;
    }
    //If all the key is ok, then run the workflow
    $json = $workflow->RunWorkflow($_POST["data"], $_POST["key"]);
    //Return the JSON result
    echo $json;
    die;
}