48 lines
1.7 KiB
PHP
48 lines
1.7 KiB
PHP
<?php
|
|
|
|
class adherent
|
|
{
|
|
protected $idAdherent;
|
|
protected $nom;
|
|
protected $prenom;
|
|
protected $req_url = 'https://librepc.com:10081/cloud/apps/oauth2/api/v1/token';
|
|
protected $authurl = 'https://librepc.com:10081/cloud/apps/oauth2/authorize';
|
|
//protected $acc_url = 'https://fireeagle.yahooapis.com/oauth/access_token';
|
|
//protected $api_url = 'https://fireeagle.yahooapis.com/api/0.1';
|
|
protected $conskey = 'your_consumer_key';
|
|
protected $conssec = 'your_consumer_secret';
|
|
|
|
function identification($idAdherent)
|
|
{
|
|
// En état state=1 la prochaine requete doit inclure le oauth_token.
|
|
// Si ce n'est pas le cas, retour à 0
|
|
if(!isset($_GET['oauth_token']) && $_SESSION['state']==1) $_SESSION['state'] = 0;
|
|
try
|
|
{
|
|
$oauth = new OAuth($conskey,$conssec,OAUTH_SIG_METHOD_HMACSHA1,OAUTH_AUTH_TYPE_URI);
|
|
$oauth->enableDebug();
|
|
if(!isset($_GET['oauth_token']) && !$_SESSION['state']) {
|
|
$request_token_info = $oauth->getRequestToken($req_url);
|
|
$_SESSION['secret'] = $request_token_info['oauth_token_secret'];
|
|
$_SESSION['state'] = 1;
|
|
header('Location: '.$authurl.'?oauth_token='.$request_token_info['oauth_token']);
|
|
exit;
|
|
} else if($_SESSION['state']==1) {
|
|
$oauth->setToken($_GET['oauth_token'],$_SESSION['secret']);
|
|
$access_token_info = $oauth->getAccessToken($acc_url);
|
|
$_SESSION['state'] = 2;
|
|
$_SESSION['token'] = $access_token_info['oauth_token'];
|
|
$_SESSION['secret'] = $access_token_info['oauth_token_secret'];
|
|
}
|
|
$oauth->setToken($_SESSION['token'],$_SESSION['secret']);
|
|
$oauth->fetch("$api_url/user.json");
|
|
$json = json_decode($oauth->getLastResponse());
|
|
print_r($json);
|
|
} catch(OAuthException $E)
|
|
{
|
|
print_r($E);
|
|
}
|
|
}
|
|
}
|
|
?>
|