Reputation: 731
I create an rest api with php usring restler libary, its work well in my PC but when I uploaded the api to server, problems begin.. this function in my api
<?php
class user {
/**
@url GET /
*/
public function getAllInfo(){
$link = new PDO('mysql:host=localhost;dbname=---;charset=utf8','---','-----');
$handle = $link->prepare('select * from user');
$handle->execute();
$result = $handle->fetchAll(PDO::FETCH_OBJ);
if(empty($result)){
$err = new stdClass();
$err->error = "No user found";
return $err;
}
else{
return $result;
}
}
require_once 'restler.php';
$r = new Restler();
$r->setSupportedFormats('JsonFormat');
$r->addAPIClass('user');
$r->handle();
?>
when I access to this page nothing appear in browser
I thought the problem is this page can't access to require_once 'restler.php';
but I was wrong, because whan I print $r->handle();
like this print_r($r->handle());
this is what I see in browser
Luracast\Restler\EventDispatcher Object ( [listeners:Luracast\Restler\EventDispatcher:private] => Array ( ) [events:protected] => Array ( ) )
I don't know what is that or what I should do to print my json, my database is full of data, its return json if my query doesn't have restler, but I need use restler with my code
Upvotes: 2
Views: 59