apis for platform agnostic communication

21
@the_dead_poetic fb.com/pupprogrammingguild github.com/awkwardusername [email protected] APIs for Platform Agnostic Communication

Upload: mark-jayson-fuentes

Post on 07-Aug-2015

141 views

Category:

Software


2 download

TRANSCRIPT

Page 1: APIs for platform agnostic communication

@the_dead_poeticfb.com/pupprogrammingguild

github.com/[email protected]

APIs for Platform Agnostic Communication

Page 2: APIs for platform agnostic communication

APIs ?

Page 3: APIs for platform agnostic communication

a set of routines, protocols, and tools for building software applications [wikipedia]

code that allows two software programs to communicate with each other [techtarget]

defines the proper way for a developer to request services from that program [computer world]

APIs are…

Page 4: APIs for platform agnostic communication

Dirty stuff

Page 5: APIs for platform agnostic communication

00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F 10 11 12 13 14 15 16 17 18 19 1A 1B 1C 1D 1E 1F20 21 22 23 24 25 26 27 28 29 2A 2B 2C 2D 2E 2F 30 31 32 33 34 35 36 37 38 39 3A 3B 3C 3D 3E 3F40 41 42 43 44 45 46 47 48 49 4A 4B 4C 4D 4E 4F 50 51 52 53 54 55 56 57 58 59 5A 5B 5C 5D 5E 5F60 61 62 63 64 65 66 67 68 69 6A 6B 6C 6D 6E 6F 70 71 72 73 74 75 76 77 78 79 7A 7B 7C 7D 7E 7F80 81 82 83 84 85 86 87 88 89 8A 8B 8C 8D 8E 8F 90 91 92 93 94 95 96 97 98 99 9A 9B 9C 9D 9E 9FA0 A1 A2 A3 A4 A5 A6 A7 A8 A9 AA AB AC AD AE AF B0 B1 B2 B3 B4 B5 B6 B7 B8 B9 BA BB BC BD BE BFC0 C1 C2 C3 C4 C5 C6 C7 C8 C9 CA CB CC CD CE CF D0 D1 D2 D3 D4 D5 D6 D7 D8 D9 DA DB DC DD DE DFE0 E1 E2 E3 E4 E5 E6 E7 E8 E9 EA EB EC ED EE EF F0 F1 F2 F3 F4 F5 F6 F7 F8 F9 FA FB FC FD FE FF

i386http://ref.x86asm.net/coder32.html

Page 6: APIs for platform agnostic communication

/* Setup cube vertex data. */v[0][0] = v[1][0] = v[2][0] = v[3][0] = -1;v[4][0] = v[5][0] = v[6][0] = v[7][0] = 1; v[0][1] = v[1][1] = v[4][1] = v[5][1] = -1; v[2][1] = v[3][1] = v[6][1] = v[7][1] = 1; v[0][2] = v[3][2] = v[4][2] = v[7][2] = 1; v[1][2] = v[2][2] = v[5][2] = v[6][2] = -1;

/* Enable a single OpenGL light. */ glLightfv(GL_LIGHT0, GL_DIFFUSE, light_diffuse); glLightfv(GL_LIGHT0, GL_POSITION, light_position); glEnable(GL_LIGHT0); glEnable(GL_LIGHTING);

/* Use depth buffering for hidden surface elimination. */ glEnable(GL_DEPTH_TEST);

/* Setup the view of the cube. */ glMatrixMode(GL_PROJECTION); gluPerspective( /* field of view in degree */ 40.0, /* aspect ratio */ 1.0, /* Z near */ 1.0, /* Z far */ 10.0); glMatrixMode(GL_MODELVIEW); gluLookAt(0.0, 0.0, 5.0, /* eye is at (0,0,5) */ 0.0, 0.0, 0.0, /* center is at (0,0,0) */ 0.0, 1.0, 0.); /* up is in positive Y direction */

OpenGL

Page 7: APIs for platform agnostic communication

#include <windows.h>

const char g_szClassName[] = "myWindowClass";

#define IDC_MAIN_EDIT 101

LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam){

switch(msg){

case WM_CREATE:{

HFONT hfDefault;HWND hEdit;

hEdit = CreateWindowEx(WS_EX_CLIENTEDGE, "EDIT", "",

WS_CHILD | WS_VISIBLE | WS_VSCROLL | WS_HSCROLL | ES_MULTILINE | ES_AUTOVSCROLL | ES_AUTOHSCROLL,

0, 0, 100, 100, hwnd, (HMENU)IDC_MAIN_EDIT, GetModuleHandle(NULL), NULL);

if(hEdit == NULL)MessageBox(hwnd, "Could not create

edit box.", "Error", MB_OK | MB_ICONERROR);

hfDefault = (HFONT)GetStockObject(DEFAULT_GUI_FONT);

SendMessage(hEdit, WM_SETFONT, (WPARAM)hfDefault, MAKELPARAM(FALSE, 0));

}break;

Windows API

Page 8: APIs for platform agnostic communication
Page 9: APIs for platform agnostic communication

POST https://api.stripe.com/v1/charges

curl https://api.stripe.com/v1/charges \ -u sk_test_BQokikJOvBiI2HlWgH4olfQ2: \ -d amount=400 \ -d currency=usd \ -d source=tok_15doRS2eZvKYlo2C2ENn4JQh \ -d description="Charge for [email protected]"

{ "id": "ch_15e7rU2eZvKYlo2CxWE8afA9", "object": "charge", "created": 1425834404, "livemode": false, "paid": true, "status": "succeeded", "amount": 4996, "currency": "usd", "refunded": false, "source": { "id": "card_15e7rT2eZvKYlo2CXYAxysRN", "object": "card", "last4": "4242", "brand": "Visa", "funding": "credit", "exp_month": 12, "exp_year": 2018, "fingerprint": "Xt5EWLLDS7FJjR1c", "country": "US", "name": null, "address_line1": null, "address_line2": null, "address_city": null, "address_state": null, "address_zip": null, "address_country": null, "cvc_check": "pass", "address_line1_check": null, "address_zip_check": null, "dynamic_last4": null, "metadata": { }, "customer": "cus_5pnSCVpMBNlSrj" }, "captured": true, "balance_transaction": "txn_15bjRh2eZvKYlo2Ch4I6lxJ7", "failure_message": null, "failure_code": null, "amount_refunded": 0, "customer": "cus_5pnSCVpMBNlSrj", "invoice": null, "description": "Charge for DOC-AID consultation for Camden Remington", "dispute": null, "metadata": { }, "statement_descriptor": null, "fraud_details": { }, "receipt_email": null, "receipt_number": null, "shipping": null, "refunds": { "object": "list", "total_count": 0, "has_more": false, "url": "/v1/charges/ch_15e7rU2eZvKYlo2CxWE8afA9/refunds", "data": [

] }}

Web Services

(this is the s**t)

Page 10: APIs for platform agnostic communication

Why APIs?

Page 11: APIs for platform agnostic communication
Page 12: APIs for platform agnostic communication

LinuxAndroidWindowsAliens

Web Services

Page 13: APIs for platform agnostic communication

Intercommunication

Page 14: APIs for platform agnostic communication

RESTfula software architecture style consisting

of guidelines and best practices for creating scalable web services.

Page 15: APIs for platform agnostic communication

Client–serverStatelessCacheableLayered system

Requirements

Page 16: APIs for platform agnostic communication

Paypal/ Stripe (Billing) OpenStreetMaps [nomatim] (Geospatial

services) data.worldbank.org (everything)

Usage of APIs

Page 17: APIs for platform agnostic communication

Virtual Hands-onLet’s do this

Page 18: APIs for platform agnostic communication

Create an app that will record the number of clicks a user makes.

The client app should be able to record from mobile devices, and web.

We should be able to see how many clicks have been pressed.

Requirements

Page 19: APIs for platform agnostic communication

Client

Page 20: APIs for platform agnostic communication

Client

Page 21: APIs for platform agnostic communication

POST http://counter.dev/count

GET http://counter.dev/count API