diuit api overview

29
DIUIT API RICH MESSAGING API BUILT FOR EVERY APP Created by / Momo Lee @zxcvbnius

Upload: ting-yi-lee

Post on 23-Jan-2018

251 views

Category:

Technology


0 download

TRANSCRIPT

DIUIT APIRICH MESSAGING API BUILT FOR EVERY APP

Created by / Momo Lee @zxcvbnius

在開始介紹之前before we start to explore diuit api

大家可以想像一下you can imagine that

NO LIMIT

HOW TO FIND EACH OTHER

HOW TO DO FILE TRANSFERRING WITHOUT SERVERBUILDING HTTP SERVICE IN YOUR APP

resuming transfer

custom securityfile live streaming

curl -X GET \ -H "range: 1200-" \ http://127.0.0.1:8080/v1/transfer

DEMOfile live streaming

A REQUEST IS LIKE A COMMANDhttps://127.0.0.1/{dosomething}

3-WAY HANDSHAKE PROBLEM想一Á情況,當你打SKYPE給朋友

我: Hi, 有沒有聽到聲音?[SYN] 某: 有,那我呢?有沒有聽到聲音[SYN, ACK]

我: 有唷~[ACK]

CHAT APIWebSocket bidirectional, full-duplex communication

+ Node.jsSocket.io

REAL-TIME COMMUNICATION

DEMOlogin , listing all chat room and sending text message

AUTHENTICATING USERAuthenticate User On Your Account ServerObtaining Authentication Nonce

Generate JWT TokenLogin to Messaging Server

curl -X GET \ -H "x-diuit-application-id: ${DIUIT_APP_ID}" \ -H "x-diuit-api-key: ${DIUIT_APP_KEY}" \ https://api.diuit.net/1/auth/nonce

curl -X POST \ -H "x-diuit-application-id: ${DIUIT_APP_ID}" \ -H "x-diuit-api-key: ${DIUIT_APP_KEY}" \ -H "Content-Type: application/json" \ -d '{"authToken":${JWT_TOKEN}, "deviceId": ${DEVICE_ID}, "platform": ${PUSH_PLATFORM}https://api.diuit.net/1/auth/login

LOGINDiuitMessagingAPI.loginWithAuthToken(new DiuitCallback<JSONObject>() { @Override public void onSuccess(final JSONObject result) { // get session // put your code } @Override public void onFailure(final int code, final JSONObject result) { // put your code } }, authToken);

LIST CHAT ROOMDiuitMessagingAPI.listChats(new DiuitCallback<ArrayList<DiuitChat>>() { @Override public void onSuccess(final ArrayList<DiuitChat> chats) { // if success, return chatArrayList }

@Override public void onFailure(final int code, final JSONObject resultObj) { // if failure, it will return error code and result } });

SEND MESSAGEchat.sendText (String text, ...); chat.sendImage(Image image, ...); chat.sendFile (File file, ...);

API DOCUMENThttp://api.diuit.com

SAMPLE CODEhttps://github.com/diuitAPI

實作如何20分×建立一Á聊天API

今日目標https://goo.gl/T1I5cI

REGISTER YOUR ACCOUNThttp://demo.diuit.net/v1/users/register

LOGINhttp://demo.diuit.net/v1/users/login

CREATE A NEW ANDROID PROJECThttps://bintray.com/duolc/maven/com.duolc.diuitapi/view

LOGIN

JOIN CHAT ROOM

SEND TEXT MESSAGING

RECEIVING MESSAGING

Remember, if you register a receiving in a activity or a obj, you have to unregister before leaving this activity ordestroy this obj.

http://developer.diuit.com/register

THANKS FOR YOUR ATTENTION