Fonctions communes:API : Différence entre versions
Ligne 7 : | Ligne 7 : | ||
$jsonfile.='"UID":"1318396",'; | $jsonfile.='"UID":"1318396",'; | ||
− | |||
$jsonfile.='"Session":"ifcu20j7de8q5m96r1ovpheog4",'; | $jsonfile.='"Session":"ifcu20j7de8q5m96r1ovpheog4",'; | ||
− | |||
$jsonfile.='"DemSoftware":"PRODON",'; | $jsonfile.='"DemSoftware":"PRODON",'; | ||
− | |||
$jsonfile.='"DemCat":"LOGIN",'; | $jsonfile.='"DemCat":"LOGIN",'; | ||
− | |||
$jsonfile.='"DemAction":"SELECT",'; | $jsonfile.='"DemAction":"SELECT",'; | ||
− | |||
$jsonfile.='"DemOptions":{"LngUID":0,"UsrEmail":"exemple@exemple.com","NomSession":""}'; | $jsonfile.='"DemOptions":{"LngUID":0,"UsrEmail":"exemple@exemple.com","NomSession":""}'; | ||
− | |||
$jsonfile.='}'; | $jsonfile.='}'; | ||
$ch=curl_init(); | $ch=curl_init(); | ||
− | |||
curl_setopt($ch,CURLOPT_URL,"<nowiki>https://192.168.0.50</nowiki>"); | curl_setopt($ch,CURLOPT_URL,"<nowiki>https://192.168.0.50</nowiki>"); | ||
− | |||
curl_setopt($ch,CURLOPT_PORT,"123"); | curl_setopt($ch,CURLOPT_PORT,"123"); | ||
− | |||
curl_setopt($ch,CURLOPT_RETURNTRANSFER,1); | curl_setopt($ch,CURLOPT_RETURNTRANSFER,1); | ||
− | |||
curl_setopt($ch,CURLOPT_POST,1); | curl_setopt($ch,CURLOPT_POST,1); | ||
− | |||
curl_setopt($ch,CURLOPT_USERPWD,"username:password"); | curl_setopt($ch,CURLOPT_USERPWD,"username:password"); | ||
− | |||
curl_setopt($ch,CURLOPT_SSL_VERIFYPEER,TRUE); | curl_setopt($ch,CURLOPT_SSL_VERIFYPEER,TRUE); | ||
− | |||
curl_setopt($ch,CURLOPT_CAINFO,"/path/to/cacert.pem"); | curl_setopt($ch,CURLOPT_CAINFO,"/path/to/cacert.pem"); | ||
− | |||
curl_setopt($ch,CURLOPT_POSTFIELDS,array("filecontenttype"=>"application/json","file"=>$jsonfile)); | curl_setopt($ch,CURLOPT_POSTFIELDS,array("filecontenttype"=>"application/json","file"=>$jsonfile)); | ||
− | |||
curl_setopt($ch,CURLOPT_SSL_VERIFYHOST,2); | curl_setopt($ch,CURLOPT_SSL_VERIFYHOST,2); | ||
− | |||
curl_setopt($ch,CURLOPT_CONNECTTIMEOUT,30); | curl_setopt($ch,CURLOPT_CONNECTTIMEOUT,30); | ||
− | |||
curl_setopt($ch,CURLOPT_TIMEOUT,30); | curl_setopt($ch,CURLOPT_TIMEOUT,30); | ||
− | |||
$result=curl_exec($ch); | $result=curl_exec($ch); | ||
Version du 24 octobre 2017 à 13:44
API |
Communications (exemple en php)
Pour utiliser l'API, les requêtes doivent passer par LDE. Voici un exemple en php servant à faire une demande à LDE afin de récupérer de l'information :
$jsonfile='{'; $jsonfile.='"UID":"1318396",'; $jsonfile.='"Session":"ifcu20j7de8q5m96r1ovpheog4",'; $jsonfile.='"DemSoftware":"PRODON",'; $jsonfile.='"DemCat":"LOGIN",'; $jsonfile.='"DemAction":"SELECT",'; $jsonfile.='"DemOptions":{"LngUID":0,"UsrEmail":"exemple@exemple.com","NomSession":""}'; $jsonfile.='}'; $ch=curl_init(); curl_setopt($ch,CURLOPT_URL,"https://192.168.0.50"); curl_setopt($ch,CURLOPT_PORT,"123"); curl_setopt($ch,CURLOPT_RETURNTRANSFER,1); curl_setopt($ch,CURLOPT_POST,1); curl_setopt($ch,CURLOPT_USERPWD,"username:password"); curl_setopt($ch,CURLOPT_SSL_VERIFYPEER,TRUE); curl_setopt($ch,CURLOPT_CAINFO,"/path/to/cacert.pem"); curl_setopt($ch,CURLOPT_POSTFIELDS,array("filecontenttype"=>"application/json","file"=>$jsonfile)); curl_setopt($ch,CURLOPT_SSL_VERIFYHOST,2); curl_setopt($ch,CURLOPT_CONNECTTIMEOUT,30); curl_setopt($ch,CURLOPT_TIMEOUT,30); $result=curl_exec($ch);
Ouverture de session
Nom du document : Fonctions communes:API