• Dear pals,
    I need to implement the REST service which explain in Simple-rest.
    I create a file with name xyz.php with code

    <?php
    if(isset($_POST['type']) && (isset($_POST['id']))) {
    	$type = $_POST['type']?$_POST['type']:"undefined";
    	$id = $_POST['id']?$_POST['id']:"undefined";
    
    	//echo "val is :".$type." id is ".$id;
    } else {
    $type = "table";
    $id = 2;
    }
    ?>
    <?php require_once("wp-load.php");?>
    <?php //get_header();
     wp_head();
    ?>
    
    <?php
    if($type=="chart" && $id!="undefined") {
    	$kk_chart = get_html_4_chart(intval($id));
    	echo $kk_chart;
    }
    if($type=="table" && $id!="undefined") {
        $kk_table = get_html_4_table(intval($id));
    	echo $kk_table;
    }
        wp_footer();
    ?>

    in root folder work fine . But i need to make it in a controller method. So I create a folder named “services” in root of WP and create a controller with name “chart” and write code as

    include_once("../wp-load.php");
    wp_head();
    wp_footer(); 
    
    class Controllers_Chart extends RestController {
    	public function get() {
    		//$this->response = array('TestResponse' => 'I am GET response. Variables sent are - ' . http_build_query($this->request['params']));
    		//$this->responseStatus = 200;
    		$kk_chart = get_html_4_chart(2);
    		return $kk_chart;
    
    	}
    }

    I just include the relevant get() method only . But I got some unexpected error like

    • Warning: include(Translation/Entry.php): failed to open stream: No such file or directory in C:\wamp\www\wp-oscar\services\index.php on line 22
    • Warning: include(): Failed opening ‘Translation/Entry.php’ for inclusion (include_path=’C:\wamp\www\wp-oscar\services;.;C:\php\pear’) in C:\wamp\www\wp-oscar\services\index.php on line 22

    alot of warning like this and a Fatal error as

      Fatal error: Call to a member function set_filenames() on a non-object in C:\wamp\www\wp-oscar\wp-content\plugins\wp-business-intelligence-lite\functions\functions.php on line 174

    please advise me a method to call WordPress Business Intelligence intelligence as a REST service .

    Waiting your reply

    Thanks,
    Anes

Viewing 1 replies (of 1 total)
  • Hi Anes,
    if the REST call you’re trying to implement is related to a specific plugin functionality. I suggest to create the service folder under the plugin directory.
    One of the error you get comes from inclusion of Translation/Entry.php.
    I don’t know what this is but probably it’s a file included by some plugin you have installed so please try to move the services directory under the WPBI root folder.
    Even the fatal error you get is due to wrong relative positions of files.
    Please implement your REST interface in a subfolder of the WPBI plugin.
    regards,
    Claudio

Viewing 1 replies (of 1 total)
  • The topic ‘How to include simple-rest library in WordPress’ is closed to new replies.