M2X IBM Bluemix PHP Demo
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").
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.
Finally, you will need the Cloudfoundry command line interface installed.
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>
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.
- Start coding with Cloud Foundry command line interface
- CF commands
- IBM Bluemix Documentation
- M2X API Documentation
This library is released under the MIT license. See
LICENSE for the terms.