Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,12 @@ get, 1 parameter
**http://localhost/latihan/wsphpserver/api.php/?action=get_app_list**
```
curl -i -H "Accept:application/json" -H "Content-Type:application/json" -XGET "http://localhost/latihan/wsphpserver/api.php/?action=get_app_list"
```
```

Kelompok 3 (D4 TI 2A)
Syarah Fauziatul Ulya (1144075)
Faizal Mutakin (1144078)
Khaera Tunnisa (1144044)
Gamma Muhammad Najmuddin (1144068)
Septian Cahya Diningrat (1144007)
Hasna Khalidah (1144116)
32 changes: 31 additions & 1 deletion api.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,30 @@ function get_app_by_id($id)
return $app_info;
}

function getBarang($id)
{
$app_info = array();

// normally this info would be pulled from a database.
// build JSON array.
switch ($id){
case 1:
$app_info = array("Nama Barang" => "Web Demo", "app_price" => "Free", "app_version" => "2.0");
break;
case 2:
$app_info = array( "Nama Barang" => "Sepatu", "Nama Vendor" => "Cantik", "Qty" => "100","Harga Satuan" => "1000000");
break;
case 3:
$app_info = array("Nama Barang" => "Tas", "Nama Vendor" => "Bagus", "Qty" => "170","Harga Satuan" => "1500000");
break;
case 4:
$app_info = array("Nama Barang" => "Dress", "Nama Vendor" => "Sally", "Qty" => "150","Harga Satuan" => "1000000");
break;
}

return $app_info;
}

function get_app_list()
{
//normally this info would be pulled from a database.
Expand All @@ -36,7 +60,7 @@ function get_app_list()
return $app_list;
}

$possible_url = array("get_app_list", "get_app");
$possible_url = array("get_app_list", "get_app", "getBarang");

$value = "An error has occurred";

Expand All @@ -53,6 +77,12 @@ function get_app_list()
else
$value = "Missing argument";
break;
case "getBarang":
if (isset($_GET["id"]))
$value = getBarang($_GET["id"]);
else
$value = "Missing argument";
break;
}
}

Expand Down