Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 66b6ef9
Showing
22 changed files
with
1,737 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,124 @@ | ||
# My Apps Session Key API Response Structures | ||
|
||
Making a GET request to the API url with the session key appended will return with a json object depending on the context with which the API was called. | ||
|
||
## API URL | ||
|
||
``` | ||
https://volare.cloud4wi.com/controlpanel/1.0/bridge/sessions/{SESSION_KEY} | ||
``` | ||
|
||
## From within the Volare Website | ||
|
||
### From Tenant level | ||
|
||
```json | ||
{ | ||
"status": "success", | ||
"data": { | ||
"lang": "eng", | ||
"auth": { | ||
"level": "tenant", | ||
"tenantId": "1001" | ||
} | ||
} | ||
} | ||
``` | ||
|
||
### From Venue level | ||
|
||
```json | ||
{ | ||
"status": "success", | ||
"data": { | ||
"lang": "eng", | ||
"auth": { | ||
"level": "wifiarea", | ||
"tenantId": "1001", | ||
"wifiareaId": "3246b0001" | ||
} | ||
} | ||
} | ||
``` | ||
|
||
## From the Access Journey | ||
|
||
### Not logged in | ||
|
||
```json | ||
{ | ||
"status": "success", | ||
"data": { | ||
"customer": { | ||
"is_logged": false, | ||
"lang": "eng" | ||
}, | ||
"hotspot": { | ||
"city": "Livorno, Italy", | ||
"id": "9067", | ||
"identifier": "685112345D_illiade", | ||
"latitude": "45.960782503827", | ||
"longitude": "12.091283106750", | ||
"mac_address": "685112345D", | ||
"name": "Odissea", | ||
"state": "Livorno", | ||
"tag": "hotspot", | ||
"zip": "Livorno", | ||
}, | ||
"tenant": { | ||
"name": "Taylor's Tenant", | ||
"read_only": false, | ||
"tenant_id": "1001" | ||
}, | ||
"wifiarea": { | ||
"name": "Livorno Venue", | ||
"wifiarea_id": "18cde0005" | ||
} | ||
} | ||
} | ||
``` | ||
|
||
### Authenticated and logged in | ||
|
||
```json | ||
{ | ||
"status": "success", | ||
"data": { | ||
"customer":{ | ||
"is_logged":true, | ||
"lang":"eng", | ||
"id":"rlC.6yTePhzYg", | ||
"first_name":"John", | ||
"last_name":"Doe", | ||
"username":"706B5C1D", | ||
"gender":"", | ||
"birth_date":"0000-00-00 00:00:00", | ||
"phone":"", | ||
"phone_prefix":"", | ||
"email":"john.doe@cloud4wi.com", | ||
"mac_address":[] | ||
}, | ||
"hotspot": { | ||
"city": "Livorno, Italy", | ||
"id": "9067", | ||
"identifier": "685112345D_illiade", | ||
"latitude": "45.960782503827", | ||
"longitude": "12.091283106750", | ||
"mac_address": "685112345D", | ||
"name": "Odissea", | ||
"state": "Livorno", | ||
"tag": "hotspot", | ||
"zip": "Livorno", | ||
}, | ||
"tenant": { | ||
"name": "Taylor's Tenant", | ||
"read_only": false, | ||
"tenant_id": "1001" | ||
}, | ||
"wifiarea": { | ||
"name": "Livorno Venue", | ||
"wifiarea_id": "18cde0005" | ||
} | ||
} | ||
} | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,112 @@ | ||
# My Apps JavaScript SDK | ||
|
||
|
||
## Including the Script in your Application | ||
|
||
The SDK can be included with your application by including the following tag in your HTML document. | ||
``` | ||
<script src="https://splashportal.sloud4wi.com/myapps/v1/myapps-sdk.js"></script> | ||
``` | ||
|
||
Including the script in your application gives access to the `MYAPPS` object. This object encapsulates a handful of functions that allow your application to integrate itself into the Access Journey provided by Volare. | ||
|
||
--- | ||
### goNext() | ||
|
||
Moves the user away from the page to the next destination on the Access Journey. | ||
|
||
Not available when application is opened from the App Bar as it is not a part of the Access Journey. | ||
|
||
```javascript | ||
MYAPPS.goNext(); | ||
``` | ||
|
||
--- | ||
### getNextUrl() | ||
|
||
Returns the URL that points to the next destination on the Access Journey. It is the same URL that would be used by the `goNext()` function to continue the Journey. | ||
|
||
Not available when application is opened from the App Bar as it is not a part of the Access Journey. | ||
|
||
```javascript | ||
MYAPPS.getNextUrl(); | ||
``` | ||
|
||
--- | ||
### goHome() | ||
|
||
Moves the user away from the page to the Welcome Portal. In many cases, has the effect of going Next, but can also have the effect of going back. Useful for App Bar applications that can use it as a "back" button in lieu of not having access to the `goNext()` function. | ||
|
||
```javascript | ||
MYAPPS.goHome(); | ||
``` | ||
|
||
--- | ||
### end() | ||
|
||
Combines `goNext()` and `goHome()`. If available, will behave as `goNext()`, but revert to `goHome()` otherwise. | ||
|
||
```javascript | ||
MYAPPS.end(); | ||
``` | ||
|
||
--- | ||
### renderNavbar(navbarOptions) | ||
|
||
Takes as an argument a JavaScript Object that contains options that are applied to the navigation bar. The options it supports are a delayed timer before the continue button is revealed, foreground and background color, and the text shown in the upper left corner. | ||
|
||
```javascript | ||
let navbarOptions = { | ||
apn: "Welcome", // Label text for upper left | ||
fontColor: "white", // Font Color | ||
backgroundColor: "black", // Background Color for gradient | ||
nextBtn: 10 // Number of seconds for delay timer | ||
} | ||
``` | ||
|
||
The options object does not have to be filled, as there are default options that can be relied upon. One simply has to ommit an entry in the object to revert to the default settings. | ||
|
||
```javascript | ||
MYAPPS.renderNavbar(navbarOptions); | ||
``` | ||
|
||
The styling is hardcoded into the `nav` tag that is produced, so apart from JavaScript manipulation, custom styling is fairly limited. | ||
|
||
--- | ||
### showNextBtn() | ||
|
||
This function changes the style of the "next" button produced by the `renderNavbar` function from `hidden` to `inline-block`. | ||
|
||
```javascript | ||
MYAPPS.showNextBtn(); | ||
``` | ||
|
||
--- | ||
### getSk() | ||
|
||
Returns the session key necessary for the [context API call](JSON_structures.md). | ||
|
||
```javascript | ||
MYAPPS.getSk(); | ||
``` | ||
|
||
--- | ||
### getParam(param) | ||
|
||
Returns the value of the given argument `param` by parsing the URL. | ||
|
||
```javascript | ||
MYAPPS.getParam(param); | ||
``` | ||
|
||
Available parameters: | ||
- `sk`: session key, used for the [context API call](JSON_structures.md) | ||
- `tgr`: step of the Access Journey that called the App | ||
- `trOpn`: Connect | ||
- `trRgt`: Sign up | ||
- `trPlgn`: Log in Attempt | ||
- `trLgn`: Log in | ||
- `trLgt`: Disconnect | ||
- `false`: When not part of the Access Journey | ||
|
||
--- |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
# Video Advertisement Demo | ||
This is a basic web application to show a video allowing the user to continue their Access Journey after a configurable amount of time. It uses the MyApps API to integrate seamlessly into the Access Journey. | ||
|
||
## Using MyApps SDK | ||
|
||
- [MyApps SDK](./MyAPPS_SDK.md) | ||
- [Context API](./ContextAPI.md) | ||
|
||
This application takes advantage of the MyApps function `MYAPPS.end()` to move along the Access Journey if available and to exit to home if opened from the App Bar. | ||
|
||
The Context API is used more heavily to associate requests with the appropriate Tenant and the Tenant's settings and for logging user data. | ||
|
||
## Main Application | ||
|
||
### Application Flow | ||
|
||
#### GET | ||
- GET request to index.php | ||
- Uses session key from GET request to pull context data from Context API | ||
- Tenant ID from Context data to pull any saved settings from MySQL | ||
- Serve page to user with settings passed into javascript via php | ||
- The page shows a loading icon until window finishes loading | ||
- The video is attempted to play, and if it succeeds, the poster is hidden and countdown started | ||
- If video fails to autoplay, poster prompts user to click it to begin countdown and video playback | ||
- If video still fails to play, countdown will commence after 10 seconds to allow user through | ||
- After countdown, Continue button is revealed which will call `MYAPPS.end()` on the `click` event | ||
|
||
#### POST | ||
- On `click` of the continue button, a post request is sent to the server with context data | ||
- Index.php uses the context data in post to create a new entry in the log files | ||
|
||
## Settings Window | ||
|
||
### Application Flow | ||
|
||
#### GET | ||
- GET request to settings.php | ||
- Uses session key from GET request to pull context data from Context API | ||
- Tenant ID from Context data to pull any saved settings from MySQL | ||
- Serve settings page to User | ||
|
||
#### POST | ||
- POST request to settings.php | ||
- Parses the data sent via JSON | ||
- Saves the parsed data to MySQL replacing the whole row | ||
- Responds with "Success!" to let the frontend know | ||
|
||
## Dependencies | ||
|
||
- Node.js, npm, and the npm packages outlined in [package.json](./package.json) | ||
- webpack used to produce `bundle.js` which is the app javascript presented to users | ||
- PHP | ||
- MySQL |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
<?php | ||
|
||
function callAPI($sk) { | ||
$url = 'https://volare.cloud4wi.com/controlpanel/1.0/bridge/sessions/' . $sk; | ||
|
||
$ch = curl_init(); | ||
curl_setopt_array($ch, array( | ||
CURLOPT_SSL_VERIFYPEER => 0, | ||
CURLOPT_RETURNTRANSFER => 1, | ||
CURLOPT_URL => $url | ||
)); | ||
|
||
$result=curl_exec($ch); | ||
curl_close($ch); | ||
|
||
return json_decode($result, true); | ||
}; | ||
|
||
function getContext($sk) { | ||
$session = callAPI($sk); | ||
$tenant = "test"; | ||
$customer = "NA"; | ||
$hotspot = "test"; | ||
|
||
if(isset($session['data']['auth'])) { | ||
$tenant = $session['data']['auth']['tenantId']; | ||
} else if(isset($session['data']['tenant'])) { | ||
$tenant = $session['data']['tenant']['tenant_id']; | ||
} | ||
|
||
if(isset($session['data'])) { | ||
$customer = $session['data']['customer']; | ||
if(isset($customer['id'])) { | ||
$customer = $customer['id']; | ||
} else { | ||
$customer = "NA"; | ||
} | ||
$hotspot = $session['data']['hotspot']['id']; | ||
} | ||
|
||
$context = array( | ||
'tenant' => $tenant, | ||
'customer' => $customer, | ||
'hotspot' => $hotspot, | ||
); | ||
return $context; | ||
}; | ||
|
||
?> |
Oops, something went wrong.