1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86
| <?php
class ConnectProAdmin {
public $curl_handle;
public $baseURL;
public $cookie;
public $account;
private $urlfinale;
//constructeur de la classe
function __construct($email,$password,$adobeBaseURL) {
$curl_handle = null;
$this->baseURL = $adobeBaseURL;
//creation de session
$this->curl_handle = curl_init();
//si aucun cookie n'est en memoire
if( !isset($this->cookie) ) {
$this->setupAdobeSessionCookie();
/* Login to the API service */
$buffer = null;
$loginURL = null;
$loginURL = "https://".$this->baseURL ."/api/xml?action=login&login=" . $email .
"&password=" . $password . "&account-id=".$this->account. "&session=" . $this->cookie;
curl_setopt($this->curl_handle, CURLOPT_URL, $loginURL);
curl_setopt($this->curl_handle, CURLOPT_CONNECTTIMEOUT ,5);
curl_setopt($this->curl_handle, CURLOPT_RETURNTRANSFER, 1);
$buffer = curl_exec($this->curl_handle);
curl_close($this->curl_handle);
if ($buffer === false) {
exit('Error2, ' . curl_error($ch) . "\n");
}
$login=simplexml_load_string($buffer);
if($login->status[-code-]=="ok"){
echo "<br/>utilisateur identifie";
//header("location:http://redirection adobe.com");
}
else{
echo "<br/>utilisateur inconnu";
}
}
}
public function getSessionCookie() {
return ($_COOKIE['BREEZESESSION'] == "") ? $this->cookie : $_COOKIE['BREEZESESSION'];
}
private function setupAdobeSessionCookie() {
$returnBuffer = null;
try{
curl_setopt($this->curl_handle, CURLOPT_URL, "http://".$this->baseURL . "/api/xml?action=common-info");
curl_setopt($this->curl_handle, CURLOPT_CONNECTTIMEOUT , 4);
curl_setopt($this->curl_handle, CURLOPT_RETURNTRANSFER , 1);
$returnBuffer = curl_exec($this->curl_handle);
}
catch(Exception $e)
{
echo "erreur :".$e;
}
// Grab the Cookie out of the server XML response
$xmlObj = simplexml_load_string($returnBuffer);
$this->cookie = $xmlObj->common->cookie;
//creation objet Dom
$dom = new DomDocument();
$dom->loadXML($returnBuffer);
$id=$dom->getElementsbyTagName("account");
foreach($id as $i){
if($i->hasAttribute("account-id"))
{
//recuperation de l'ID du compte
$this->account=$i->getAttribute("account-id");
}
}
}
}
?> |
Partager