AT&T M2X Bluemix Demo Application for PHP
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
CONTRIBUTING.md
LICENSE
Procfile
README.md
composer.json
composer.lock
icon.png
loadreport.php
master.py

README.md

M2X IBM Bluemix PHP Demo

Introduction

This repo provides a framework for an IBM Bluemix application with PHP code that reports data to AT&T M2X. The application reports the current system load every minute.

Please note that Bluemix and M2X are using times in UTC, not in your local time zone. M2X will, however, accept data in any time zone as long as the timestamp is formatted using ISO8601 (e.g. "2015-02-27T18:14:00.000-03:00").

Pre-Requisites

You will need to have an IBM ID (sign-up here). The account you make will be a free trial account that is good for 30 days. If you confirm your account using a credit card, this application will still be free to run because it only needs one instance and less than 512MB of memory.

You will also need an account on AT&T's M2X service, which has a free Developer plan and usage based paid plans for higher volumes of data. Check out the M2X Pricing page for more details.

Finally, you will need the Cloudfoundry command line interface installed.

Instructions

Creating Your Application

$ git clone https://github.com/attm2x/m2x-demo-bluemix-php.git
$ cd m2x-demo-bluemix-php

Connect, login and deploy to Bluemix

Make sure you have installed the Cloudfoundry command line interface for your system.

First connect to Bluemix.

$ cf api https://api.ng.bluemix.net

Then login using your IBM ID.

$ cf login -u <email used as IBM ID>
$ cf target -o <email used as IBM ID> -s dev

Deploy the app, but don't start it yet (you will need your M2X API Master Key first).

$ cf push <app name> -m 512m -c "python master.py" --no-route --no-start

M2X API Key

To get your M2X API Master Key, login to M2X, and click your name in the upper right-hand corner, then the "Account Settings" dropdown, then the "Master Keys" tab. Here's a direct link.

Then you'll need to add your key as an environment variable on your Bluemix instance:

$ cf set-env <app name> M2X_API_KEY <M2X API Master Key>

Finally, start your application.

cf start <app name>

Testing

Your loadreport.php should now be reporting the system load to AT&T M2X every minute.. (Please note that the NYSE is open from 9:30 AM to 4 PM Eastern Time, and the stock price reported outside those hours will not change.)

If there are any errors, they will be logged via Bluemix's log system. Use cf logs <app name> --recent to see the live output from your application.

Useful Links

License

This library is released under the MIT license. See LICENSE for the terms.