My Last Day at Appery.io

Conference badges

Friday, May 5th 2017 was my last day at Appery.io. I’m taking a small break right now and will be starting my next adventure next week.

How to Send a Fax with Appery.io and Twilio Fax API

Twilio launched a new API that allows sending faxes. From the very start Appery.io platform made it very simple to connect to any external REST API. We love Twilio API and have an example and video on how to use the SMS API. The Fax API is as elegant and simple to use. In this blog post you will learn how to send a fax using the Twilio Fax API from a Server Code script.

Create a new Server Code script and copy the following script:

var url = "https://fax.twilio.com/v1/Faxes";
var accountSid = "AC3526fbeed7...............";
var token = "8703513246d3f445e............";
var to = "To number";
var from = "Your Twilio number"
var mediaUrl = "https://www.twilio.com/docs/documents/25/justthefaxmaam.pdf";

var XHRResponse = XHR2.send("POST", url, {
   "body": "To=" + encodeURIComponent(to) + "&From=" + encodeURIComponent(from) + "&MediaUrl="+mediaUrl,
   "headers": {
      Authorization: "Basic " + encodeBase64(accountSid + ":" + token),
      "Content-Type": "application/x-www-form-urlencoded"
   }
});

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

The script is simple and does a POST request to the Twilio Fax API.

Line 1 is the Twilio Fax API endpoint.

Line 2 and 3 are Twilio Account SID and Auth Token. You can get both from the console dashboard.

Line 4 is where to send the fax (number).

Line 5 is your Twilio number.

Line 6 is a link to a document you want to fax. You can set it to any PDF file accessible via a direct link (or use the sample one provided by Twilio).

Line 8 is where the POST request is invoked with all the information.

Twilio Fax API uses Basic Authentication so the Account SID and Auth Token need to be encoded as Base64. There is an out-of-the-box plug-in that you can add to your account. The plug-in has a function to encode a string as Base64.

  1. Open the dropdown list (on the left) and select Back to list.
  2. Open the Plugins tab.
  3. Find the EncodeBase64 plugin and click insert to add it to your account. The plugin will be listed in the Library section. You can now use it in any other script.
  4. One more step is to add this library as a dependency for your script. Open that script you created. Go to Dependencies tab and click on EncodeBase64_Library.

You are ready to test the script.

Go back to the Script tab and open the Run tab (on the right). Click on Save and run button to invoke the API and send the fax.

The response should look like this:

{
   "date_updated": "2017-04-06T13:13:40Z",
   "date_created": "2017-04-06T13:13:40Z",
   "num_pages": null,
   "api_version": "v1",
   "media_url": null,
   "url":
   "https://fax.twilio.com/v1/Faxes/FX225bab5034cb8a335c45...............",
   "sid": "FX225bab5034cb8a335c45...............",
   "quality": "fine",
   "duration": null,
   "price_unit": null,
   "price": null,
   "account_sid": "AC3526fbeed7...............",
   "from": "+1415xxxxxxx",
   "to": "+1925xxxxxxx",
   "status": "queued",
   "direction": "outbound"
}

You can navigate to the URL set in the url attribute – there you will be able to see the status of the sent fax (the browser will ask you to login, use the Account SID and Auth Token values).

It can take a few minutes for the fax to be delivered, keep that in mind when testing. If you fax the pre-set PDF file then yon you will the following fax:

twilio-just-the-fax-man
Twilio sample fax

To learn more about Server Code check the Appery.io YouTube playlist. Happy faxing.

How to Expose a Database Stored Procedure and a Function as a REST API

Appery.io API Express makes it easy to expose a SQL query as a REST API. You can as easily expose a database stored procedure or a database function as a REST API. The following two blogs posts will teach you how to do that:

Want to learn more about API Express? Check our the Appery.io YouTube channel for videos on how to integrate with external data sources using API Express.

 

How Not to Send a Marketing Email

Today I received this email:

Subject: reconnect [company name]

Hi Max,

I noticed that Appery, LLC and [company name] had been in contact in the past and thought now would be a good time to reconnect.

Do you have a few minutes this afternoon?

[name]
Marketing Specialist

I deleted the email but then looked at it again.

There is absolutely zero value in this email (besides writing this blog post). Even if we had been in contact before, what are we connecting about now? This email shows that very little effort was put into writing this email.

I’d expect the first word in the subject to be capitalized. Also, there is no reason to say Appery, LLC. We don’t say Twitter Inc., or Facebook Inc.

If you want us to reconnect please tell me why you think we should connect. Maybe you just released a brand new API and built an app using Appery.io and want to show me the app so we can write a blog post about it. Something like this.

Video: How to Call WordPress REST API

Watch this short video to learn how to call the WordPress REST API from an Appery.io app. The video shows two approaches invoking the API.  First, it shows how to invoke an API using API Express. Second, it shows how to invoke an API from Server Code.

If you like this video, check the Appery.io YouTube channel for many more short videos to help you build apps faster.

Exposing a SQL Database via REST APIs: A Video Guide for Developers

Many organizations that are building mobile apps need to connect and reuse existing (internal) systems. One of the most common system is a relational (SQL) database. The question is — how to a relational database from a mobile app.

I have prepared two short videos that will show you how to do that using Appery.io API Express.

API Express connects to a relational database and exposes the database tables via REST APIs. Once the APIs are created, the mobile app can easily consume the APIs.

There are two approaches exposing a database:

The first approach automatically generates CRUD-like APIs to work with a database table. In many apps, this is close to 80% of what an app might need. This automatic approach also comes with very sophisticated offline support. In other words, you app can work offline and sync data with a remote database when a connection is reestablished.

With the second approach, you get full control as you write the actual SQL query (or Stored Procedure) that will be executed. With this approach, you can use a visual service editor to orchestrate the REST API. In addition to the SQL component (connector), you can use connectors such as Web Service (WSDL), REST  and others.

Check out the API Express video playlist to learn more.

How Appery.io Ensures API Express and Server Code On-demand Deployment

apperyio_ondemand_sc_aex_scheme

Appery.io had a strong 2016 and inches closer and closer to 400,000 developers. At the same time, the constant platform updates we roll out add more benefits, services, features, and options. Even without the constant updates, supporting a platform with so many developers would not be a simple task. Our platform has to be ready for continuous updates, increased load, and new user requests and requirements.

We want to provide high SLA level services and avoid unexpected slowdowns and downtimes for customers’ apps even during peak hours. To provide the required scalability and resilience, we rely on industry leader Amazon Web Services and its various features such as Auto Scaling, Launch Configurations, and CloudWatch.

In this blog post you will learn how exactly we ensure scalability and resilience for Appery.io API Express and Server Code services.

Continue reading on the Appery.io blog.

 

22 Things You Should Know About Appery.io Server Code

 

Appery.io Server Code allows you to write app logic with JavaScript which is executed on the server. Custom app logic is placed inside a Server Code script which is than invoked as a REST API from a mobile app. In this post you will learn everything you should know about Appery.io Server Code.

  1. Server Code is a server-side component in the Appery.io cloud platform.
  2. The code (logic) is placed inside a script which is executed on the server.
  3. You can write any custom app logic (you have access to most JavaScript APIs).
  4. The language used to write the Server Code script is JavaScript.
  5. A script is invoked as a REST API from a mobile app.
  6. A script can be tested (invoked) inside the Server Code dashboard.
  7. A script can depend on one more more libraries. A library is a reusable script (JavaScript code also).
  8. A script can connect and query the Appery.io Database.
  9. A script can send, manage and schedule Appery.io Push Notificationsa.
  10. A script can connect and invoke any 3rd party (external) REST API.
  11. A script can be secured with a username and password.
  12. A script can be scheduled as Job to run periodically and on schedule.
  13. A script can invoke another script.
  14. You can create versions of a script.
  15. A script has very fast cache called In Memory Data (data lives for 20 minutes).
  16. A script can be invoked from Appery.io API Express service flow.
  17. The script editor comes with Snippets, small reusable code which can be quickly inserted into a script.
  18. Server Code comes with Plug-ins. Plug-ins are scripts and libraries that can be quickly inserted and provide specific functionality such as integration with 3rd party APIs.
  19. A script has a Trace page where you can view console and error messages from script execution.
  20. A script has a Statistics page where you can view various statistics about a script such as how many times a script was invoked.
  21. A  script has a description field which can be invoked via a separate REST API for documentation purpose.
  22. The JavaScript engine used for Server Code is Nashorn.

Want to try Appery.io? Sign up for a free trial account in seconds.

Watch the Server Code YouTube playlist to learn more.

Ringing in 2017 With a Big Appery.io Platform Update

The Appery.io team just pushed a big platform update with exciting new features:

  • iOS 10 Support
  • Apache Cordova Upgrade
  • Automatically Sync Backend Services Changes with the App Builder
  • Organize with Folders Inside the App Builder
  • Backend Services APIs Are Now Placed in Folders for Easier Organization
  • Improved Media Manager
  • Improved Synchronization Between App and Server for Apps with Offline Support
  • New Page to Test API Express Services and Offline Support
  • New Auto-login with Offline Support
  • IPv6 Network Support
  • Improved Server Code on Demand Balancing
  • And More…

Read about this update on the Appery.io blog.

How to Convert Phone Numbers Into Real Business Data with EveryoneAPI

EveryoneAPI by Telo allows to convert a phone number into real business intelligence with a simple API request. The complete reverse phone append product is simple to use, yet powerful and built for developers by developers. As you probably already know, integrating with any 3rd party REST API using the Appery.io Server Code is also simple. In this blog post, I will show you how to invoke a test a script that calls the Everyone API.

To start, create a new Server Code script with the following code:

var telephone = request.get("telephone");
var url = "https://api.everyoneapi.com/v1/phone/"+telephone;
var auth_token  = "AU83e975.....";
var account_sid = "AC659275.....";

var XHRResponse = XHR2.send("GET", url, {
   "parameters": {
      "auth_token": auth_token,
      "account_sid": account_sid,
      "pretty": "true"
   }
});
Apperyio.response.success(XHRResponse.body, "application/json");

The only thing you need to do, is to replace the auth_token and account_sid with values from your account. Sign up for an account here. It’s fast and simple.

The phone number for which you want to get information is passed as a parameter to the script (line 1). To test the script, switch to Script parameter tab (on the right side), enter a parameter called telephone and then set it to a test value. Here is an example testing the API using the Appery.io telephone number:

everyoneap_servercode.png
AnyoneAPI Server Code script

Once you finished and tested the script, you easily import into your app. This video shows how to do that.

Looking for more APIs by Telo? Check out the CallerID Server Code plug-in:

callerid_servercode_plugin.png
Caller ID Server Code plug-in

This plug-in creates a Server Code script that integrates with OpenCNAM API. The OpenCNAM API allows you to get caller ID information for phone number provided.