This method does requires authentication.
This method is called with HTTP method GET.
| Argument | Type | Element (array) | Valid Values | Default Value | Detail |
|---|---|---|---|---|---|
token |
string | authenticated session id (stored in the session $_SESSION['token']) | required | User Token |
| Element (path) | Name | Type | Description | |||||
|---|---|---|---|---|---|---|---|---|
| / | nb_results | int | total number of products | |||||
| /[n]/ | id | int | product unique ID | |||||
| /[n]/ | title | string | product title (used for title tag) | |||||
| /[n]/ | data | array | the other data for a product like size, orientation, backside, price, etc. | |||||
| / | text | array |
|
GET http://testapi.wannaprint.com/Rest/1/[API Key]/api/listProducts/token=[token]
<?php
session_start();
$api_items = $apicaller->sendRequest(array(
'controller' => 'api',
'action' => 'listProducts',
'token' => $_SESSION['token']
));
foreach($api_items->text as $text)
{
echo $text;
}
if($api_items->nb_results>0)
{
echo "
<strong>Products:</strong>
<table border='0'>
<tr>
<th>ID</th>
<th>Title</th>
<th>Data 1</th>
<th>Data 2</th>
<th>Data 3</th>
<th>Data 4</th>
...
</tr>
";
for($i=1; $i<=$api_items->nb_results; $i++)
{
echo '
<tr>
<td align="center">'.$api_items->$i->id.'</td>
<td>'.$api_items->$i->title.'</td>
<td>'.$api_items->$i->data->data1.'</td>
<td>'.$api_items->$i->data->data2.'</td>
<td>'.$api_items->$i->data->data3.'</td>
<td>'.$api_items->$i->data->data4.'</td>
...
lt;/tr>';
}
echo "
</table>";
}
?>
{
"text":["SUCCESS"],
"1":{
"id":"1",
"title":"Business cards",
"data":{
size":"8,5 x 5,5 cm \/ 9 x 5 cm",
"price":"0",
"quantites":[
250,
500,
1000,
2000,
3000,
4000,
5000,
6000,
7000,
8000,
9000,
10000
],
"backsides":[
"Vierge",
"\"Imprimé par www.cartevisite.com\"",
"impression en noir",
"impression couleur"
],
"orientation":[
"Paysage",
"Portrait"
]
},
"nb_results":1
}
or
{
"text":["ERROR: You have to be authentified to use this method!"]
}
001: Wrong API Key002: Failed to parse request011: Controller is invalid.031: Invalid Method