Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- if( getenv("VCAP_SERVICES") ) {
- echo "hello";
- $services = getenv("VCAP_SERVICES");
- $services_json = json_decode($services, true);
- echo json_encode($services_json);
- $mysql_config = $services_json["iotf-service"][0]["credentials"];
- $org_id = $mysql_config["org"];
- $port = $mysql_config["mqtt_u_port"];
- $username = $mysql_config["apiKey"];
- $password = $mysql_config["apiToken"];
- }
- // set configuration values
- $config = array(
- 'org_id' => $org_id,
- 'port' => $port,
- 'app_id' => 'mymqttfinalservice',
- 'iotf_api_key' => $username,
- 'iotf_api_secret' => $password,
- 'device_id' => 'abcdef',
- 'qos' => 1
- );
- $config['server'] = $config['org_id'] . '.messaging.internetofthings.ibmcloud.com';
- $config['client_id'] = 'a:' . $config['org_id'] . ':' . $config['app_id'];
- $location = array();
- // initialize client
- $mqtt = new phpMQTT($config['server'], $config['port'], $config['client_id']);
- $mqtt->debug = false;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement