Skip to content

Instantly share code, notes, and snippets.

@itayher
itayher / ioniccreator.md
Last active October 20, 2017 06:28
How to add Backand to Ionic Creator

In order to enable Backand in Ionic Creator follow these steps:

Add Config File

Under 'Other JS' add new file name bkndconfig.js, with this code (override the entrire code in the page):

angular.module('app.config', [])
// remember to add "app.config" to your angular modules in Code Settings

.config(function(BackandProvider) {
@itayher
itayher / sendAttachmentWithMandrill.md
Last active February 21, 2023 11:15
Example how to send email with attachment in Mandrill using Backand node.js server side action

Example how to send email with attachment in Mandrill using Backand node.js server side action

Installations

  1. Create new node.js on-demand action
  2. Create acction in Mandrill and copy the API KEY
  3. Follow the instruciton by running npm backand and 'backand action deploy' command

Code Update

In index.js file add these lines before 'exports.backandCallback' function.

Get Access Token

PHP cURL

<?php

$curl = curl_init();

curl_setopt_array($curl, array(

Check access_token is valid

HttpRequest

<?php

$request = new HttpRequest();
$request->setUrl('https://api.backand.com/1/objects/action/users/1');
$request->setMethod(HTTP_METH_GET);

Get Access Token

HttpRequest:

<?php

$request = new HttpRequest();
$request->setUrl('https://api.backand.com/token');
$request->setMethod(HTTP_METH_POST);

Creating your own Facebook Messenger Bot with Backand

Facebook recently opened up their Messenger platform to enable bots to converse with users through Facebook Apps and on Facebook Pages. In support of this, the Facebook Messenger team created a comprehensive set of documentation describing the functionality on offer. While they offer a lot of functionality and platform-level integration for free, you still need to create a publicly-accessible application that Facebook can communicate with in order to communicate with your end users.

In this tutorial, we'll walk through creating your own messenger bot with a back-end ready to go, powered by Backand and live - all in 10 minutes.

In order to have socket works for Backand in Angular 1.x (without Backand's SDK) do the follow:

Add this line to index.html:

  <script src="https://api.backand.com:4000/socket.io/socket.io.js"></script>

Use this service 'SocketService' for the main socket functionality:

Android code with authentication to use with Back&:

com.backand.backandandroidsample;

import android.util.Base64;
import android.util.Log;

import java.io.InputStream;
import java.io.InputStreamReader;

Use this code snippet of Android in order to access Back&, make a GET call that returns string which you can transform into JSON:

StringBuilder stringBuilder = new StringBuilder();
try {
    String authorization = "<< AnonymousToken >>";

    HttpsURLConnection conn = (HttpsURLConnection) url.openConnection();
 conn.setRequestMethod("GET");

###Basic Auth To use Admin's permission in the server side action or imperonsate to other user use basic auth Authorization header:

###Back& server side Action In the action change the headers code to be this line:

headers:{'Authorization':'basic ' + btoa (username + ':'+ password) }