Cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted

How to read data in php

Experimenter
Experimenter

Hello!

 

I just started looking into Mindsphere and I have a developer account.

I usually code apps i php and have mostly done websites with SQL connetion.

 

Now I am trying to understand the function of Mindsphere apps.

I have installed CloudFoundry and set this up, so thats OK.

 

What I can not find (or understand) is how do I access my data points?

If I want to read the latest value (say Integer) from

 

Asset: tenant.variabletest

Variable: myData

 

<?php

$latest_data_value = ????;

?>

 

2 REPLIES 2

Re: How to read data in php

Siemens Genius Siemens Genius
Siemens Genius

Hi @alo-dafo ,

 

MindSphere offers multiple REST-Endpoints that provide the IoT-related data. In case you have already created an asset and ingested data, then you can read the following pages for further information:

 

 

And here is a short summary of the necessary steps:

  1. Create application with the correct requests and proper setup authentication and authorization for the requests
  2. Register your application in the Developer Cockpit
  3. Assign the MindSphere APIs to your application specific roles, in that case most likely the Asset Management and the TimeSeries API roles. See the Roles and Scopes for further details.

 

Regards

Michael

Re: How to read data in php

Experimenter
Experimenter

Thank you for the reply @MichaelE .

 

I am still confused.

I want to use a self-hosted PHP app. 

I have understood that I need to create a secret key and access this via REST endpoint, and use OAuth ?

(All this is new to me but I would like to learn). How do I create this key?

Do I need to create a "virtual" app in developer cockpit for my self-hosted app?
How do I grant permissions to my datapoints so I can access these from my self-hosted app?

 

Is there someone that can give me a code sample of the PHP code required?

How do I address the data points? Example asset: tenant.variabletest, variable: myData

 

I find the documentation very confusing and lack examples.

 

I am also confused in how to generate my secret key / token? How to use the Token manager? The documentation for this is also very confusing. Where do I find the token manager? 

 

I'm on a developer plan.

 

Thanks in advance,

Daniel