Skip to content

Instantly share code, notes, and snippets.

@notFloran
Created June 15, 2013 14:19
Show Gist options
  • Save notFloran/5788302 to your computer and use it in GitHub Desktop.
Save notFloran/5788302 to your computer and use it in GitHub Desktop.
Connexion à l'API Neufbox
<?php
#Config
$apiUrl = "http://192.168.1.1/api/1.0/";
$user = "admin";
$password = "";
$tokenXML = simplexml_load_file( $apiUrl . "?method=auth.getToken" );
$token = $tokenXML->auth[0]->attributes()->token;
$hmacUser = hash_hmac('sha256', hash('sha256', $user), $token);
$hmacPassword = hash_hmac('sha256', hash('sha256', $password), $token);
$hash = $hmacUser . $hmacPassword;
$authXML = simplexml_load_file( $apiUrl . "?method=auth.checkToken&token=" . $token . "&hash=" . $hash );
if( $authXML->attributes()->stat == "ok" ) {
$authToken = $authXML->auth->attributes()->token;
// command
// http://www.neufbox4.org/wiki/index.php?title=API
// http://dev.efixo.net/doc/api-rest.html
}
else {
echo "Erreur !";
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment