All posts by mitch

Creating PINs

Before you’re able to use this process please contact sales@42com.com to generate a complete pin creation account for usage of the api!
You’ll get a username/password combination to use this process.

For all processes you need the cli paramter which is always named „Telefon“ during the processes.

Creating cards

Parameter: m „mycard-v2“
Parameter: act „insert“
Parameter: Telefon [country code e.g. +49 for Germany & mobile number e.g. 49179900000]
Parameter: Kunde name of the customer [could be the same like Telefon]
Parameter: Amount amount in EUR
Parameter: sendSmsInfo should the customer receive a sms?
Parameter: smsinfo_message text 4 the sms [if empty we’ll send a default template]

Request:

  'm' => string 'mycard-v2' (length=9)
  'v' => string 'json' (length=4)
  'act' => string 'insert' (length=11)
  'Kunde' => string '' (length=0)
  'Telefon' => string '4917990000000' (length=12)
  'Amount' => string '0.10' (length=1)
  'sendSmsInfo' => string '1' (length=1)

Response Body:

{
    "error": false,
    "codes": [
        {
            "code": 200,
            "description": "OK"
        }
    ],
    "body": {
        "Kunde": "4917990000000",
        "CLI": "4917990000000",
        "Amount": "0,10 EUR",
        "AmountAll": "0,10 EUR",
        "fldSerial": "12871384",
        "fldPIN": "321582778",
        "active": 1
	}
    }
}

Getting status of a cards

Parameter: m „mycard-v2“
Parameter: act „show“
Parameter: Telefon

Request:

  'm' => string 'mycard-v2' (length=9)
  'v' => string 'json' (length=4)
  'act' => string 'show' (length=11)
  'Telefon' => string '4917990000000' (length=12)

Response Body:

{
    "error": false,
    "codes": [
        {
            "code": 200,
            "description": "OK"
        }
    ],
    "body": {
        "Kunde": "4917990000000",
        "CLI": "4917990000000",
        "Amount": "0,10 EUR",
        "AmountAll": "0,10 EUR",
        "fldSerial": "12871384",
        "fldPIN": "321582778",
        "active": 1
	}
    }
}

If „active“ is empty, the card is blocked!

Blocking cards

Parameter: m „mycard-v2“
Parameter: act „blockcard“
Parameter: Telefon

Request:

  'm' => string 'mycard-v2' (length=9)
  'v' => string 'json' (length=4)
  'act' => string 'blockcard' (length=11)
  'Telefon' => string '4917990000000' (length=12)

Response Body:

{
    "error": false,
    "codes": [
        {
            "code": 200,
            "description": "OK"
        }
    ],
    "body": {
        "Kunde": "4917990000000",
        "CLI": "4917990000000",
        "Amount": "0,10 EUR",
        "AmountAll": "0,10 EUR",
        "fldSerial": "12871384",
        "fldPIN": "321582778",
        "active": ''
	}
    }
}

Un-Blocking cards

Parameter: m „mycard-v2“
Parameter: act „unblockcard“
Parameter: Telefon

Request:

  'm' => string 'mycard-v2' (length=9)
  'v' => string 'json' (length=4)
  'act' => string 'unblockcard' (length=11)
  'Telefon' => string '4917990000000' (length=12)

Response Body:

{
    "error": false,
    "codes": [
        {
            "code": 200,
            "description": "OK"
        }
    ],
    "body": {
        "Kunde": "4917990000000",
        "CLI": "4917990000000",
        "Amount": "0,10 EUR",
        "AmountAll": "0,10 EUR",
        "fldSerial": "12871384",
        "fldPIN": "321582778",
        "active": 1
	}
    }
}

Disable Cards

Parameter: m „mycard-v2“
Parameter: act „disableCliByNumber“
Parameter: realm
Parameter: cli Telefon

Request:

  'm' => string 'mycard-v2' (length=9)
  'v' => string 'json' (length=4)
  'act' => string 'disableCliByNumber' (length=11)
  'realm' => string 'testRealm' (length=50)
  'cli' => string '4917990000000' (length=12)

Response Body:

{
    "error": false,
    "codes": [
        {
            "code": 200,
            "description": "OK"
        }
    ],
    "body": {
        "Kunde": "4917990000000",
        "CLI": "4917990000000",
        "Amount": "0,10 EUR",
        "AmountAll": "0,10 EUR",
        "fldSerial": "12871384",
        "fldPIN": "321582778",
        "active": ' '
	}
    }
}

Change CLI

Parameter: m „mycard-v2“
Parameter: act „changeCliByNumber“
Parameter: realm
Parameter: cli Current telefon
Parameter: newCli New telefon

Request:

  'm' => string 'mycard-v2' (length=9)
  'v' => string 'json' (length=4)
  'act' => string 'changeCliByNumber' (length=11)
  'realm' => string 'testRealm' (length=50)
  'cli' => string '4917990000000' (length=12)
  'newCli' => string '4917990000001' (length=12)

Response Body:

{
    "error": false,
    "codes": [
        {
            "code": 200,
            "description": "OK"
        }
    ],
    "body": {
        "Kunde": "4917990000000",
        "CLI": "4917990000001",
        "Amount": "0,10 EUR",
        "AmountAll": "0,10 EUR",
        "fldSerial": "12871384",
        "fldPIN": "321582778",
        "active": 1
	}
    }
}

Activate Cards

Parameter: m „mycard-v2“
Parameter: act „activateMyCard“
Parameter: realm
Parameter: cli Telefon
Parameter: PIN „321582778“

Request:

  'm' => string 'mycard-v2' (length=9)
  'v' => string 'json' (length=4)
  'act' => string 'activateMyCard' (length=11)
  'realm' => string 'testRealm' (length=50)
  'cli' => string '4917990000000' (length=12)
  'PIN' => string '321582778' (length=12)

Response Body:

{
    "error": false,
    "codes": [
        {
            "code": 200,
            "description": "OK"
        }
    ],
    "body": {
        "Kunde": "4917990000000",
        "CLI": "4917990000000",
        "Amount": "0,10 EUR",
        "AmountAll": "0,10 EUR",
        "fldSerial": "12871384",
        "fldPIN": "321582778",
        "active": 1
	}
    }
}

Number Check

To verify a complete number use this api process.

Parameter: prefix [country code e.g. +49 for Germany]
Parameter: number

GET https://login.42call.com/api/rest/v3/number-check?prefix=49&number=123456798

Request Headers:

Connection: keep-alive
x-date: 2014-02-20 18:23:38.000000 GMT+0000
x-authorization: demo:2ZigDbwB0bX32zmjGgKB+vB/Q74=
Host: login.42call.com

Response Body:

{
    "error": false,
    "codes": [
        {
            "code": 200,
            "description": "OK"
        }
    ],
    "body": {
		"completenumber": "49179123456789",
		"prefix": "49179",
		"number": "123456789",
		"name": "Germany Mobile O2"
	}
    }
}

Try the example on /42com/number-check/

Small Ember.js and SMS Example

There is a new small code example on github for how to use ember.js and the 42com REST API v3.
Ember.js is an open-source client-side JavaScript web application framework based on the model-view-controller (MVC) software architectural pattern. It allows developers to create scalable single-page applications[1] by incorporating common idioms and best practices into a framework that provides a rich object model, declarative two-way data binding, computed properties, automatically-updating templates powered by Handlebars.js, and a router for managing application state [Wikipedia].
See it in action at 42call.

Authentication Javascript

It is really simple to build a small website using our API.
We do not care about Same-Origin-Policy so you’re able to build web applications running on web servers, as APPs on mobile devices and as applications at the personal computer.

For this example we provide the code on guthub named 42call-sms.
You need to include some library’s to start over.

Start with the correct date format for the x-date header parameter.

var now = new Date();
date = new Date(now.getTime());
date = date.toISOString();

Then hash the users password with md5.

var passMd5 = CryptoJS.MD5($('#password').val());
passMd5 = passMd5.toString();

Combine the date and the md5 password with an line break and encode it with the md5 password.

var hash = CryptoJS.HmacSHA1(passMd5+"\n"+date, passMd5);
hash = hash.toString(CryptoJS.enc.Base64);

The preparation of the header is done. So fire the request to the api url like /api/rest/v2/?sms.

$.ajax({
    type:"POST",
    headers : {
        "x-date" : date,
        "x-authorization" : $('#inputUsername').val()+":"+hash,
}, 
    data: { act: "sendSms", phonenumbers : '123465798', message : 'hello world!'},
    url: "https://login.42call.com/api/rest/v2/?sms"
}).done(function(data) {
    alert(data);
    $.mobile.loading('hide');
});

Done.
More about SMS here.

Account

Details of the current user could be fetched with the resource account.

GET http://login.42call.com/api/rest/v2/?account

Request Headers:

Connection: keep-alive
x-date: 2014-02-20 18:23:38.000000 GMT+0000
x-authorization: demo:2ZigDbwB0bX32zmjGgKB+vB/Q74=
Host: login.42call.com

Response Body:

{
    "error": false,
    "codes": [
        {
            "code": 200,
            "description": "OK"
        }
    ],
    "body": {
        "accounts": [
            {
                "customername": "Demo Kunde",
                "customernumber": "00216559",
                "accountnumber": "7346165",
                "amount": "15,4426",
                "accountname": "Account, Demo"
            }
        ]
    }
}

Call detail records (for callshops)

How to get the latest call detail records of an callshop account. The module is named cdr-callshop and it will work like that.

Parameter: from (date)
Parameter: to (date)

GET http://login.42call.com/api/rest/v2/?cdr-callshop&from=2014-02-01&to=2014-02-20&show=2

Request Headers:

Connection: keep-alive
x-date: 2014-02-20 18:23:38.000000 GMT+0000
x-authorization: demo:2ZigDbwB0bX32zmjGgKB+vB/Q74=
Host: login.42call.com

Response Body:

{
    "error": false,
    "codes": [
        {
            "code": 200,
            "description": "OK"
        }
    ],
    "body": {
        "cdrs": [
            {
                "data": "2014-02-20 21:51:56.000",
                "caller": "00493019991390875",
                "callee": "0049179123456",
                "duration": "4",
                "billingduration": "4",
                "comment": "Germany Mobile O2",
                "amount": "0,0012",
                "amounttax": "0,0012"
            },
            {
                "data": "2014-02-20 21:51:56.000",
                "caller": "00493019991390875",
                "callee": "0049179123456",
                "duration": "4",
                "billingduration": "4",
                "comment": "Germany Mobile O2",
                "amount": "0,0053",
                "amounttax": "0,0053"
            },
            {
                "data": "2014-02-20 21:51:56.000",
                "caller": "00493019991390875",
                "callee": "0049179123456",
                "duration": "4",
                "billingduration": "4",
                "comment": "Germany Mobile O2",
                "amount": "0,0012",
                "amounttax": "0,0012"
            }
        ]
    }
}

If there is no record available right now, the body tree is an empty array.
Example page.

Topup

top up single account

Using personal identification numbers (PIN) to charge or load up an account can be used for cashcards and/or callingcards. In both cases we’re checking every single PIN on validity and affiliation. You just need to request the given PIN and the api will response with the success state.

Request POST http://login.42call.com/api/rest/v2/?topup

POST data:

{
 "pin": "123456"
}

Request Headers:

Connection: keep-alive
x-date: 2014-02-20 17:34:00.000000 GMT+0000
x-authorization: demo:wjZGsoP5yejpksp/ofqlwEOjom8=
Content-Type: application/x-www-form-urlencoded
Content-Length: 25
Host: login.42call.com

Response body:

{
    "error": true,
    "codes": [
        {
            "code": 1200,
            "description": "Personal Identification Number Not Valid"
        }
    ],
    "body": []
}

error codes

http://login.42call.com/api/rest/v2/

Voip account

To get the list of existing voip lines to an active account you might call the voiplist module.
The response will consist of all valid accounts connected to the active user session.
For security reasons the password will be base64 coded in the response.

Request GET http://login.42call.com/api/rest/v2/?voiplist

Request Headers:

m: "voiplist">Connection: keep-alive
x-date: 2014-02-20 17:43:52.000000 GMT+0000
x-authorization: demo:q4ybUBzn+kTHgACWPgiqGAy+Sk0=
Host: login.42call.com

Response body:

{
    "error": false,
    "codes": [
        {
            "code": 200,
            "description": "OK"
        }
    ],
    "body": {
        "voiplist": {
            "sip_1": {
                "type": "SIP",
                "username": "demo",
                "password": "demo",
                "ip": "111.222.333.444:50123",
                "domain": "",
                "stun_server": "",
                "proxy": "",
                "prefix": "",
                "transport_tls": "false",
                "transport_tcp": "true",
                "transport_udp": "false",
                "transport_use_standard_ports": "true",
                "forbid_self_call": "true",
                "echo_cancellation": "false",
                "escape_plus": "false",
                "enable_outbound_proxy": "false",
                "wifi_only": "false",
                "unknown_incoming_call_name": "Unbekannt",
                "codec_speex16": "true",
                "codec_speex8": "true",
                "codec_ilbc": "true"
            }
        },
        "customernumber": "1234",
        "accountnumber": "1234",
        "username": "demo",
        "customercurrency": "eur",
        "customeraccountstate": "18,40"
    }
}

Rates

single number

To get the customers rate for a destination we’re providing the rates module. It’s really easy to use. You just need to bring the dialled destination and the back end engine will split it into the prefix and the destination name. The request will respond with the name, the price, the prefix and the user currency for the given number.

GET http://login.42call.com/api/rest/v2/?rates&numbers=0177123456|030123456

Request Headers:

Connection: keep-alive
x-date: 2014-02-20 17:51:47.000000 GMT+0000
x-authorization: demo:VpxszNu25G+Kca3oHni3mkfRQm8=
Host: login.42call.com

Response Body:

{
    "error": false,
    "codes": [
        {
            "code": 200,
            "description": "OK"
        }
    ],
    "body": {
        "currency": "EUR",
        "rates": [
            [
                {
                    "number": "0177123456",
                    "destinationname": "Germany Mobile EPlus",
                    "price": "0,10",
                    "prefix": "0049177"
                },
                {
                    "number": "030123456",
                    "destinationname": "Germany",
                    "price": "0,04",
                    "prefix": "0049"
                }
            ]
        ]
    }
}

Test the endpint with Mashape.