Getting the list of (current) subscriptions for an User.
support, ws.webtv, api, store, subscriptions

GET vars specific to this request:
| Var | Value | Description |
| go | store | The API section |
| do | list_subscriptions | The API action |
| iq | User ID | The User ID |
Resulting Request URL:
The resulting request URL would be similar to this (don't forget to append the required info: key, timestamp, salt and signature):
https://....../api.php?go=store&do=list_subscriptions&iq={user_id}&{required information}
None. No POST vars are required for this request.
If the request was successful, you'll receive a response containing:
• list: (array) An array with the subscription list (the array can be empty). Each one will inlude:
- content_title: (string) The title of the content associated to the subscription.
- date_end: (int) Unix timestamp, end date (renewal date) for the subscription.
- date_end_formatted_d: (string) The previous value, formatted (date part).
- date_end_formatted_t: (string) The previous value, formatted (time part).
- id: (int) subscription ID.
- id_product: (int) ID of the product related to this subscription.
- renewable: (int 0|1) Whether the subscription is renewable (if renewable, the WebTV will ask the user to pay on renewal date - or, in case of existing a recurring payments profile, it will use the associated payment method to check whether the corresponding payment was made).
- subscription_number: (string) the number of the subscription.
*** Recurring payments related data ***
- rp_profile_id: (string) The ID of the recurring payment profile (in case there is any).
- rp_status: (string) The status of the recurring payment profile (if any) (blank, Active, Pending, Cancelled, Suspended, Expired, ...).
- rp_amount: (decimal) The amount billed on each renewal.
- rp_amount_formatted: (string) The previous value, formatted.
- rp_currency_code: (string) The currency code.
- rp_date_last_payment: (int) Unix timestamp, the date when the last recurring payment was made.
- rp_date_last_payment_formatted_d: (string) The previous value, formatted (date part).
- rp_date_last_payment_formatted_t: (string) The previous value, formatted (time part).
- rp_date_start: (int) Unix timestamp, the date when the first recurring payment will be (or was) made.
- rp_date_start_formatted_d: (string) The previous value, formatted (date part).
- rp_date_start_formatted_t: (string) The previous value, formatted (time part).
- rp_id_payment_method: (int) ID of the payment method used for the recurring payments.
- rp_period_unit: (int) The time unit of the billing period (DAY, WEEK, MONTH or YEAR).
- rp_period_amount: (int) The amount/frequency of the billing period.
Example:
{
"list": [{
"content_title": "Premium Channel",
"date_end": "1509177992",
"date_end_formatted_d": "28\/10\/2017",
"date_end_formatted_t": "10:06:32 AM",
"id": "26",
"id_product": "6",
"renewable": "1",
"rp_amount": "10.00",
"rp_amount_formatted": "10\u20ac",
"rp_currency_code": "EUR",
"rp_date_last_payment": "0",
"rp_date_last_payment_formatted_d": "",
"rp_date_last_payment_formatted_t": "",
"rp_date_start": "1508916090",
"rp_date_start_formatted_d": "25\/10\/2017",
"rp_date_start_formatted_t": "09:21:30 AM",
"rp_id_payment_method": "3",
"rp_period_amount": "1",
"rp_period_unit": "MONTH",
"rp_profile_id": "MyUniqueExtAPIProfileID",
"rp_status": "Active",
"subscription_number": "SUBS00026"
}]
}
If the request failed (for example, if no signature was provided in the request), you'll receive a response like the following:
{
"error" : "REQUEST_ERROR",
"error_long" : "Missing signature"
}
Possible Error Messages
Besides the general errors, this request can return the following errors:
• REQUEST_ERROR | Invalid User ID:
User ID is not numeric or lower than 1.
Preparing GET and POST data.
// The GET vars $GET_VARS = array( "go" => "store", "do" => "list_subscriptions", "iq" => "2" ); // The POST vars $POST_VARS = array();
Generating the salt, timestamp, signature and sending the request
*** The following code block is common to all signed requests ***
// Collect the API Base URL and Credential info
$API_URL = "https://www.mywebtvdomain.tv/api.php";
$API_KEY_ID = "1b323a1cb879fd4e66530fbad07a32ee";
$API_SHARED_SECRET = "MWIzMjNhMWNiODc5ZmQ0ZTY2NTMwZmJhZDA3YTMyZWViOTQ3MDJiOGM2ZTU2NjE3"; // keep this safe!!!
// Generating salt and timestamp
$salt = md5(mt_rand());
$timestamp = time();
$signature = base64_encode(hash_hmac('sha256', $salt.$timestamp, $API_SHARED_SECRET, true));
// Generating the validation signature
// - Default method: using base64_encode(hash_hmac(...))
$signature = base64_encode(hash_hmac('sha256', $salt.$timestamp, $API_SHARED_SECRET, true)); // comment this line if using the next method
// - Simplified method - available since v60: using md5().
// This method requires the variable $API_SIGNATURE_GENERATION_MODE = 1; in the config/Config.inc.php file.
// $signature = md5($salt."-".$timestamp."-".$API_SHARED_SECRET); // you must "uncomment" this line when using the simplified method
// Append the timestamp, salt, key and signature to the GET vars
$GET_VARS["timestamp"] = $timestamp; // UTC timestamp
$GET_VARS["salt"] = $salt;
$GET_VARS["key"] = $API_KEY_ID ; // The API Key ID: This is public and is used by the API to identify the application;
$GET_VARS["signature"] = $signature;
// Create the request URL. Please note that if you do not use PHP buit in function
// to create the HTTP query then don't forget to URL encode the values
$REQUEST_URL = $API_URL."?".http_build_query($GET_VARS);
// The previous will build an URL like .../api.php?go=api_subject&do=api_action&etc...
// Create a new cURL resource and set the appropriate options
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $REQUEST_URL);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HEADER, false);
curl_setopt($ch, CURLOPT_POSTFIELDS, $POST_VARS);
// If your PHP host does not have a valid SSL certificate, you will need to turn off SSL
// Certificate Verification. This is dangerous (!), and should only be done temporarily
// until a valid certificate has been installed
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false); // Turns off verification of the SSL certificate.
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); // Turns off verification of the SSL certificate.
// Sending the request to the API
$response = curl_exec($ch);
// Processing the response
if (!$response) {
echo 'API call failed';
}
else
{
print_r(json_decode($response,true));
}


