Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $password="YOUR_NETATMO_API_PASSWORD";
- $username="YOUR_NETATMO_API_EMAIL";
- $app_id = "APP_ID_FROM_API";
- $app_secret = "APP_SECRET_FROM_API";
- $token_url = "https://api.netatmo.net/oauth2/token";
- $postdata = http_build_query(
- array(
- 'grant_type' => "password",
- 'client_id' => $app_id,
- 'client_secret' => $app_secret,
- 'username' => $username,
- 'password' => $password,
- 'scope' => "read_camera"
- )
- );
- $opts = array('http' =>
- array(
- 'method' => 'POST',
- 'header' => 'Content-type: application/x-www-form-urlencoded',
- 'content' => $postdata
- )
- );
- $context = stream_context_create($opts);
- $response = file_get_contents($token_url, false, $context);
- $params = null;
- $params = json_decode($response, true);
- $api_url = "https://api.netatmo.net/api/getuser?access_token=" . $params['access_token'];
- $requete = file_get_contents($api_url);
- $url_welcome = "https://api.netatmo.net/api/gethomedata?access_token=" . $params['access_token'] . "&size=1";
- $welcome = file_get_contents($url_welcome);
- echo $welcome;
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement