VNP Output Webservices - User/Subscriber infos
This webservice allows to retrive infos about any existing VirtualNewspaper user account and its previous completed orders.
This webservice can be triggered to retrieve details about the orders POST or GET request as follows:
http://[wwx].virtualnewspaper.it/editorName/webservice/getUserOrders.jsp?email='subscriber@email.com'&authCode='your_own_VNP_authCode'
Warning:
This POST call needs to be url encoded
Webservice Mandatory Parameters
Subscriber email address and VNP authCode are needed as mandatory parameters in this data workflow.
The authCode can be calculated adding the email address provided as first parameter, plus your VirtualNewspaper privateKey (you can find this key within the "Settings" pane of your VirtualNewspaper back-end).
This VirtualNewspaper webservice is able to provide two different replies :
01) The email provided is from a valid VirtualNewspaper user account.
In this scenario VirtualNewspaper JSON reply will look like this :
{
customerId: 2715636,
address: "viale ariosto 328",
email: "username@email.com",
status: 1,
name: "John",
gender: "_",
surname: "Doe",
orders: [
{
detailOrder: [
{
totalCredits: 12,
detailOrderId: 1193577,
price: 0,
editionsConsulted: "",
productCode: "",
expireDate: "2015-05-12",
idProduct: 141,
activationDate: "2014-05-13",
productName: "one year subscription",
currency: "EUR"
}
],
confirmed: 1,
date: "2014-05-13",
orderId: 1173568
},
{
detailOrder: [
{
totalCredits: 1,
detailOrderId: 1193576,
price: 0,
editionsConsulted: "130801edition;",
productCode: "DIGITQRTSING",
expireDate: "2015-05-12",
idProduct: 40,
activationDate: "2014-05-13",
productName: "Single Copy",
currency: "EUR"
}
],
confirmed: 1,
date: "2014-05-13",
orderId: 1173567
}
],
town: "Firenze",
password: "08cf56a1e2c7d2da70c03b861e6dd506",
mobile: ""
}
02) Something went wrong.
In this scenario VirtualNewspaper JSON reply will look like this :
{
error: "missing user",
status: 0
}
| PARAMETER NAME | VALUE FORMAT | Description |
|---|---|---|
| varchar(255) | Email address from the VNP user you want retrieve informations about | |
| authCode | string | a MD5 of the email+privateKey |
Code Example
private static String readAll(java.io.Reader rd) throws java.io.IOException {
StringBuilder sb = new StringBuilder();
int cp;
while ((cp = rd.read()) != -1) {
sb.append((char) cp);
}
return sb.toString();
}
public static org.json.JSONObject readJsonFromUrl(String url) throws java.io.IOException, org.json.JSONException {
org.json.JSONObject json = null;
try {
java.io.InputStream is = new java.net.URL(url).openStream();
java.io.InputStreamReader isr=new java.io.InputStreamReader(is, "UTF-8");
java.io.BufferedReader rd = new java.io.BufferedReader(isr);
String jsonText = readAll(rd);
json = new org.json.JSONObject(jsonText);
is.close(); rd.close(); isr.close();
} catch(Exception e) {
}
return json;
}
String email = "username@email.com";
String pk = "thePrivateKey"
String authCode = md5(email+pk);
String url = "virtualnewspaper.editor.com/sso/getUserByEmail.jsp?email="+email+"&authCode="+authCode
org.json.JSONObject json = utilita.Utilities.readJsonFromUrl(url);
if (json.getInt("status")==1) {
// Store (or update) and login the user
}