Virus Free No Ads
When you receive a phone call, 2 parameters are sent: name and number. The app will look into your contacts to find the name corresponding to the number. If there is no match, name will be an empty string.
When it's a text message, a third parameter is sent containing the message. So you have just to verify is the parameter message exists to find out if it's a phone call or a message.
A server example written in PHP can be found here: https://github.com/nawrasg/Call-Notifier
Call Notifier is a free app without ads. Source code is available on Github: https://github.com/nawrasg/Call-Notifier