我在php中创建了restful webservices来连接数据和app。 在我的本地主机中,我得到了所有东西,但我没有在godaddy服务器中获得任何输出。
<?php
require_once("Rest.inc.php");
class API extends REST {
public $data = "";
const DB_SERVER = "localhost";
const DB_USER = "root";
const DB_PASSWORD = "";
const DB = "beta01";
private $db = NULL;
public function __construct(){
parent::__construct();
$this->dbConnect();
}
private function dbConnect(){
$this->db = mysql_connect(self::DB_SERVER,self::DB_USER,self::DB_PASSWORD);
if($this->db)
mysql_select_db(self::DB,$this->db);
}
public function processApi(){
$func = strtolower(trim(str_replace("/","",$_REQUEST['rquest'])));
if((int)method_exists($this,$func) > 0)
$this->$func();
else
$this->response('',404);
}
private function users(){
if($this->get_request_method() != "GET"){
$this->response('',406);
}
$sql = mysql_query("SELECT * FROM users", $this->db);
if(mysql_num_rows($sql) > 0){
$result = array();
while($rlt = mysql_fetch_array($sql,MYSQL_ASSOC)){
$result[] = $rlt;
}
$this->response($this->json($result), 200);
}
$this->response('',204);
}