How to Connect to FullContact API From Appery.io Server Code

FullContact Developer APIs such as Person API, Company API, Email API and others can provide social profiles in an app, improve contacts in address book, enrich CRM information, and create marketing campaigns.

To make it simple to use FullContact API, we created a Server Code plug-in that quickly creates a script to invoke the Person API. You only need to set the FullContact API key. The following animated GIF shows how to insert the FullContact plug-in and its script:

fullcontact_servercode

Once you set the API key, it’s fast to test the script and the API. Switch to Run tab to test the script. The script comes with a sample email. Feel free to change the input data.

FullContact_ServerCode_run-1024x429.png

Script testing

You can also set the email as a script parameter. Update the script code to look like this:

var email = request.get("email");

and then add the parameter on Script parameters tab.

Using the Server Code plug-in for FullContact API it’s fast and simple to invoke the Person API. Using this plug-in as a starting point, you can update the script to include other API parameters or use other APIs.

Using Geolocation in a Mobile App: A Video Guide

Geolocation is one of the most widely used APIs in mobile apps today. From weather to Uber and Lyft, the device location is crucial information and many APIs use it to determine what services and products are available in a given location. When building a mobile app in Appery.io, using the Geolocation API is simple. Apache Cordova library is built-in in every new Appery.io app. Invoking Geolocation will return the latitude, longitude (and other) information which can then be passed to any REST API. The following two short videos show how to use and invoke Geolocation in an Ionic and jQuery Mobile apps:

Looking for more videos like that? Check Appery.io YouTube channel for many more videos.

Appery.io Platform Overview: A Video Guide for Mobile Developers

This video provides a high-level overview of the Appery.io Platform. Using one-slide, the video goes over the major platform features and benefits. Whether you are new or an existing Appery.io user, this is a great video to get an overview how to build apps on the platform.

 

Check out the Appery.io YouTube channel for more videos like this.

Find Out How to Build Cordova Apps Fast

One of the core components in Appery.io platform is a cloud build service which builds a binary file (hybrid) for iOS or Android. Appery.io leverages Apache Cordova (PhoneGap) to create a binary file. Launching the build process is very simple. Right from inside the App builder, clicking the Export button you will see the option to create a binary file for iOS or Android.

 

apperyio_export

Export menu

 

Once Binary (.ipa) or Binary (.apk) is selected, the build process starts. The build process usually takes one minute. When the build is completed, the file is downloaded to your computer. From there you can publish the app to an app store, using the standard publishing process for each store.

Learn more about how to use Apache Cordova in Appery.io to build hybrid apps and use native APIs.

 

A Quick Guide to Sending Push Notifications

Being able to send Push Notifications to users is one of the fundamental capability in an enterprise mobile app. Appery.io platform comes with Push Notifications component out-of-the-box and allows you quickly to send targeted messages to iOS and Android devices. In this blog post we will show the four ways to send a Push Notification message to a user:

  1. Push Notifications Console.
  2. Server Code Push Notifications API (server-side).
  3. Push Notification REST API.
  4. Customer Console.

Push Notifications Console

This first option is probably the simplest way to send a Push Notifications once you have installed an app on a device. Select device types, enter the message and send. The Push Notification message should arrive on the registered device instantly.

 

PN_console.png

Push Notifications console.

 

Continue reading

Quickly Invoke Lyft API from Appery.io Server Code

Appery.io Server Code makes it simple to invoke any external REST API. In this blog post, I will show you how to invoke Lyft API. I will use the Ride Types API to show what types of cars are available based on a location – latitude and longitude. Lyft is a ride sharing company that’s disrupting car ownership and moving forward with self-driving cars initiative.

Let’s start with the tutorial.

The first step is to perform authentication to get an access token to invoke any Lyft API. As the Ride Types API doesn’t use any user data, you can use client credentials for authentication. The script to get an access token looks like this:

var url = "https://api.lyft.com/oauth/token";
var client_id = "<client_id>";
var client_secret = "<client_secret>";

var XHRResponse = XHR2.send("POST", url, {
  "body": {
    "grant_type": "client_credentials",
    "scope": "public"
  },
  "headers": {
    "Content-Type": "application/json",
    "Authorization": "Basic "+encodeBase64(client_id+":"+client_secret)
  }
});
Apperyio.response.success(XHRResponse.body, "application/json");

The response will look like this:

{
   "expires_in": 86400,
   "token_type": "Bearer",
   "scope": "public",
   "access_token": "<access_token>"
}

Once you have the access_token, it is as simple to invoke the Ride Types API:

var url = "https://api.lyft.com/v1/ridetypes"; // REST API URL

var XHRResponse = XHR2.send("GET", url, {
  "parameters": {
    "lat": "37.7833", // San Francisco
    "lng": "-122.4167"
  },
  "headers": {
    "Authorization": "Bearer " + &lt;access_token&gt;
  }
});
Apperyio.response.success(XHRResponse.body, "application/json");

The response looks like this, it shows the type of rides available in San Francisco: Lyft, Lyft Line, and Lyft Plus.

{
	"ride_types": [{
		"ride_type": "lyft_line",
		"pricing_details": {
			"cost_per_minute": 23,
			"base_charge": 200,
			"currency": "USD",
			"trust_and_service": 175,
			"cost_per_mile": 115,
			"cancel_penalty_amount": 500,
			"cost_minimum": 475
		},
		"image_url": "https://s3.amazonaws.com/api.lyft.com/assets/car_standard.png",
		"seats": 2,
		"display_name": "Lyft Line"
	}, {
		"display_name": "Lyft",
		"image_url": "https://s3.amazonaws.com/api.lyft.com/assets/car_standard.png",
		"pricing_details": {
			"cost_minimum": 500,
			"cost_per_minute": 23,
			"base_charge": 200,
			"currency": "USD",
			"trust_and_service": 175,
			"cost_per_mile": 115,
			"cancel_penalty_amount": 500
		},
		"ride_type": "lyft",
		"seats": 4
	}, {
		"display_name": "Lyft Plus",
		"ride_type": "lyft_plus",
		"image_url": "https://s3.amazonaws.com/api.lyft.com/assets/car_plus.png",
		"seats": 6,
		"pricing_details": {
			"currency": "USD",
			"cost_minimum": 700,
			"cost_per_mile": 200,
			"trust_and_service": 175,
			"cancel_penalty_amount": 500,
			"cost_per_minute": 30,
			"base_charge": 300
		}
	}]
}

Want to learn how to build mobile apps fast? Check out the Appery.io YouTube channel for videos.

Video Tutorial: How to Build and Test a Complete Mobile App with API Backend

This video shows how to build and test a complete Ionic app with an API backend. The tutorial starts by showing how to create an app backend with API Express by connecting to an external REST API. Then, the tutorial shows how to build an Ionic app and import the backend service into the app. The tutorial also shows how to make a small change to the generated code. The tutorial then shows how to test the app in the browser and also on a device using the Appery.io Tester app. Lastly, the tutorial shows where to build a binary file for iOS or Android for submission to an app store.

Check out other videos on how to build mobile apps fast.

Learn How to Perform Basic Database Operations: Create, Read, Update, and Delete

The Appery.io Backend Services consists of the following components:

  • Database – for storing any app data.
  • Server Code – for writing server-side app logic using JavaScript.
  • API Express – integrating with external systems and APIs.
  • Push Notifications – sending push messages to devices.
  • Web Hosting – publishing and hosting mobile web apps.

In this post, we will show you how a Server Code script integrates with the Database.

One of the most common questions we get is how to work with the database, how to create, edit and delete data. This makes sense as virtually any mobile app needs to store data in a database and perform these basic operations. To access the database, we are going to use Server Code script. Server Code allows writing app logic using JavaScript which will be executed on the server. For example, a script can access the database, send a Push Notification message, sort data and invoke an external REST API. We will start with the most basic operation: how to read data from the database.

The database collection used in this post looks like this:

crud_collection

Database collection.

This can be data collected from a form inside an app – a form that collects information about the user.

Reading Data

Server Code script has out-of-the-box API to access the database to perform all the basic operations. The following script reads all objects from the above collection.

var dbApiKey = "fe7c124b-f7c5-4764-9274-173b56a97102";
var result = Collection.query(dbApiKey, "Data");
Apperyio.response.success(result, "application/json");

One line 2, the script retrieves all the data.

One line 3, the script response is set. A Server Code script is invoked as a REST API. The code on this line defines the API response.

A script can be quickly tested from the Run tab where you can see the JSON data:

 

crud_test

Script testing.

 

Reading data from a database collection is fast and simple. Next, we are going to save data into the database.

Continue reading

How to Build and Test an Ionic SMS App

This video shows how to build and test an Ionic SMS app using Nexmo API. The video tutorial first shows how to create a backend to invoke Nexmo API. Then the Ionic app is created which uses the backend. The app is then tested in the browser and on the device using the Appery.io Tester app. The video also shows how to build a binary file for Android and iOS.

Looking for more videos to help build mobile apps? Check out the Appery.io YouTube channel.

Video Tutorial: How to Build a REST API for a Custom SQL Query

This video shows how to use the SQL and Script components to build a Login service. The SQL component runs a custom SQL query to check if a user exists in a database. The Script component adds custom logic to check what the SQL component returned and defines the response (user found or user not found).

Looking for more videos on enterprise integration? Watch the API Express playlist.