How to Pass Parameters to a Cloud Function

In my previous blog post I showed how to invoke an external REST API from a cloud function. The API that I used returns a random (Chuck Norris 💪) joke. In this blog post I want to show you to how pass a parameter to the cloud function. We can pass a joke number to the API and get that particular joke back 🤣.

Using the code from the previous blog post:

var request = require("request");

function main(params) {
   var options = {
      url: "https://api.icndb.com/jokes/random",
      json: true
   };

   return new Promise(function (resolve, reject) {
      request(options, function (err, resp) {
         if (err) {
            console.log(err);
            return reject({err: err});
         }
      return resolve({joke:resp.body.value.joke});
      });
   });
}

to get a particular joke number, change the URL to look like this:

url: "https://api.icndb.com/jokes/" + params.joke

params – passed to main function is a JSON object that holds parameters (input) to this cloud function.

Continue reading “How to Pass Parameters to a Cloud Function”

Introduction to Kubernetes Lunch & Learn – Video Recording

The San Francisco Developer Advocacy team hosted another great Lunch & Learn event. The topic was Kubernetes. The session covered what is Kubernetes, how it works and what are its benefits? The session was lead by Andy Shi and Anthony Amase.  Here is what the session covered and then jump to the session video recording.

  • Problems that need to be solved in the micro-services world and how does K8s solve them?
  • Benefits K8s brings to DevOps
  • Concepts and terminologies in K8s
  • A demo showcasing the features and benefits of K8s on the IBM Cloud platform

Are you in the Bay Area and want to learn about AI, Blockchain, Serverless, Kubernetes, Istio, Chatbots and other technologies – come to our upcoming free developer workshops.

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.

Integrating With PayPal API for Mobile Payments

PayPal is obviously one of the most popular services and APIs to use when you want to support payments in you mobile app. This tutorial will show you how to create a single payment using Appery.io Server Code. You can the use it as a starting point for all other APIs made available by PayPal.

If you read the PayPal documentation, the first step is to get a token so you can invoke PayPal APIs. Before you can get the token, you need to create an app in PayPal:

Screen Shot 2016-04-27 at 4.25.01 PM
Apps in PayPal

Every app has a Client ID and Secret values that you need to use to get a token.

Screen Shot 2016-04-27 at 4.31.49 PM
Client ID and Secret

The Server Code script below sends a request to PayPal to get a token:

var url = "https://api.sandbox.paypal.com/v1/oauth2/token";

var XHRResponse = XHR2.send("POST", url, {
  "parameters": {
    "grant_type": "client_credentials"
  },
  "headers": {
    "Accept": "application/json",
    "Accept-Language": "en_US",
    "Authorization": "Basic clientid:secret_as_base64"
});

Apperyio.response.success(XHRResponse.body, "application/json");

The response looks like this:

{
 "app_id": "APP-80W2.....",
 "access_token": "A101.VyA8xBdNyOY.....",
 "token_type": "Bearer",
 "scope": "https://uri.paypal.com/....",
 "nonce": "2016-04-27T23:15:21Zahq3.....",
 "expires_in": 31284
}

The access_token is what you need to invoke any other PayPal API.

Now that you have the token, you can invoke any PayPal API. In the next script I create a payment (charge):

var url = "https://api.sandbox.paypal.com/v1/payments/payment";

var XHRResponse = XHR2.send("POST", url, {
 "headers": {
    "Content-type": "application/json",
    "Authorization": "Bearer A101.VyA8xBdNyOY....."
 },
 "body": {
    "intent": "sale",
    "payer": {
       "payment_method": "credit_card",
       "funding_instruments": [{
          "credit_card": {
             "number": "4060xxxxxxxxxxxx",
             "type": "visa",
             "expire_month": 06,
             "expire_year": 2019,
             "cvv2": "874",
             "first_name": "Betsy",
             "last_name": "Buyer",
             "billing_address": {
                "line1": "111 First Street",
                "city": "Saratoga",
                "state": "CA",
                "postal_code": "95070",
                "country_code": "US"
             }
          }
       }]
    },
    "transactions": [{
       "amount": {
          "total": "7.47",
          "currency": "USD",
          "details": {
             "subtotal": "7.41",
             "tax": "0.03",
             "shipping": "0.03"
          }
       },
       "description": "This is the payment transaction description."
       }]
    }
});

Apperyio.response.success(XHRResponse.body, "application/json");

The payment example was adopted from PayPal API documentation

One important thing you need to do is use a valid credit card number from your test account. Without a valid credit card number, the request will not work. To find your credit card number go to Sandbox > Accounts, expand your account and click Profile. Select the Funding tab and use the credit card and expiration data from there for the test payment.

Once you have a working Server Code script that creates a payment in PayPal, you can use the script in your mobile app. A Server Code script is automatically exposed via a REST API which you can call from your app. We have many videos on our YouTube channel that show how to use Server Code and other Appery.io backend services.

Build a Text Messaging App in 5 Minutes

This 5-minute video shows how to build a text (SMS) messaging app in about 5 minutes. The app uses Twilio SMS API. After watching the video you will learn:

  • How to build app UI using Appery.io visual editor
  • Setup and test a REST API service (Twilio)
  • Bind the service to the page
  • Test the app

Liked this video? Check our the rest of our Build in 5 Minutes videos.

Make Your Mobile App Secure with MetaCert Security API

meta-cert-pluingWe are happy to announce that we have worked with MetaCert to provide a security API to enable our developers to protect their apps from malicious and unwanted links.

Most mobile malware is downloaded when end users click on malicious links inside legitimate apps. The MetaCert Security API adds a thin, but very powerful, layer of security to your app.

The API allows you to check the reputation of web links in real time, providing an invisibly secure experience. It can be used to block phishing sites from loading or navigating to. You can also stop end-users from sharing links that are NSFW.

To make it even simpler to use the MetaCert Security API, we have published a MetaCert plug-in. Appery.io developers can quickly add the plug-in to any new or existing app and check for the reputation of any web links in the app.

Continue reading “Make Your Mobile App Secure with MetaCert Security API”

4-Minute Video on Creating Responsive App with Bootstrap, AngularJS and Appery.io

4-minute video on creating a responsive app with Bootstrap, AngularJS in Appery.io

View more videos on Appery.io Youtube channel.

Video: Building a Mobile App with User Login and Registration in Appery.io

This video shows how to build a mobile app in Appery.io with user login and registration. The video covers:

  • Creating a page that has login and registration forms
  • Using Appery.io Database for User Management
  • Generating and mapping login and registration API services
  • Using Appery.io Server Code to record each user login and then display the history of logins on the welcome page
  • Setting up security for server script and database

Pressure to Deliver Enterprise Mobile Apps Fast

Darryl Taft from eWeek published a great article: No-Code Platforms, Cloud Services Offer Options for Mobile App Dev. The article talks about pressure enterprises face today to deliver mobile apps fast.  The article also covers Appery.io. An excerpt is below and full article here.

Mobile app development environment provider Exadel’s Appery.io offers a cloud-based rapid development environment with integrated back-end services and a catalog of API plug-ins that simplify integration with cloud services and enterprise systems.

As part of its solution, Appery.io also features a no-code, RAD environment.

“Our cloud-based mobile platform requires no coding, but it’s unique in that it also supports the needs of professional programmers,” Francisco Kattan, vice president of marketing at Exadel, told eWEEK. “It’s not like codeless tools are replacing coding tools; it’s about empowering a much broader base of developers to innovate. The number of Java, C++ and C# programmers is limited and we can’t keep up with demand.”

Kattan said Exadel expects that 25 percent of all apps that will be developed for the enterprise by 2015 will be built using codeless tools. He also cited a Gartner report that predicts that by 2018 more than half of all apps will be built with codeless tools.

“We have a graphical development environment, but we don’t limit you to the GUI,” he said.

Appery.io recently announced it has reached more than 150,000 developers that are using the platform.

Getting into the specifics of the platform, Max Katz, head of developer relations for Appery.io, said, “We always start with HTML5. Then we can take that HTML5/JavaScript app and package it for mobile. We use PhoneGap/Apache Cordova. We can build mobile, web apps or hybrid apps.”

Among the system’s underlying technology is HTML5, JavaScript, CSS, jQuery Mobile, PhoneGap, Bootstrap and MongoDB, among other things, Katz said.

“We researched all the leading mobile app platforms and, chose Appery.io for its intuitive visual development environment, integrated backend services and its catalog of API plug-ins,” said JC Lin, CEO of Zagama, an app development company in Asia that has partnered with Appery.io. “Appery.io’s intuitive visual environment assists customers in overcoming the barriers affiliated with cross-platforms so developers can work on a project remotely and simultaneously.”

Exadel’s Kattan says Appery.io offers a complete mobile app development platform—not just tools but complete backend services in the form of an MBaaS.

“MBaaS environments are essentially cloud-based collections of fine-grained services intended to support mobile developers,” Hilwa told eWEEK. “Mobile developers tend to be front-end focused and love the handholding they get for setting up back-ends which is usually challenging for their skill-sets. The majority of MBaaS companies were born three to four years ago to target consumer environments, but some have recently started targeting enterprises.”

Read the entire article.

Make Great Enterprise Mobile Apps with Appery.io – Bay Area Enterprise Mobile App Development Meetup

I will be at Bay Area Enterprise Mobile App Development meetup on October 23, 2014 showing how to build great apps with Appery.io. Hope you can be there.

What

Using APIs and cloud tools for rapid mobile app development

Gone are the days where you can afford to take months to build an enterprise mobile app. In today’s fast market, you need to be able to prototype the app in a few days, release the first version in a few weeks, get feedback, fix bugs, release the second version. Repeat. In this session you will learn how to use APIs and cloud platform for rapid mobile development. We will use the Appery.io mobile platform to build a real app. This is a live coding session where you will be able to test the app on your phone, and we will package the app for iOS/Android.

When

Thursday, October 23, 2014, 6:00 PM to 8:00 PM

Food

Beer and pizza

Attend

Yes, I want free beer and learn how to build enterprise mobile apps