I have to create a webservice for mobile application(IPhone and Android) in Rest Service. This Application is based one E-Publishing. I try some REST service based on SLIM . I can able to add a data into db and also retrieve the data from DB.
I use the following link to develop REST Service
http://phpmaster.com/writing-a-restful-web-service-with-slim/
I am able to add a new data through form in html but i want to use url to add a data. but i cant. here is the code i used
<form action="http://localhost/samples/Restfull/samp5/index.php/custom" method="POST">
<input type="hidden" name="_METHOD" value="POST">
Name: <input type="text" name="Customer_Name"><br>
Mobile: <input type="text" name="Customer_Mobile"><br>
Email: <input type="text" name="Customer_Email"><br>
Address: <textarea name="Customer_Address"></textarea>
<br>
<input type="submit" value="Submit">
</form>
When i try through this form , the operation is successfully done. But i want to make that as web service. I try to add data through url but failed, at the same time Delete or get data by using join queries also not working.
I retrieve data from Db by using following function
$app->get("/custom/:id", function ($id) use ($app, $db) {
$app->response()->header("Content-Type", "application/json");
$custom = $db->Registration()->where("Registration_Id", $id);
if ($data = $custom->fetch()) {
echo json_encode(array(
"custom_Name" => $data["Customer_Name"],
"custom_Mobile" => $data["Customer_Mobile"],
"custom_Email" => $data["Customer_Email"],
"custom_Address" => $data["Customer_Address"]
));
}
else{
echo json_encode(array(
"status" => false,
"message" => " $id does not exist"
));
}
});
This also works well.
Is any other way or good samples available. Not only in Slim. I need to integrate REST Service. Please suggest on this.
Thanks in advance.