Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
**Fix:**
- Fixed return error for 'searchEtablissement' function
  • Loading branch information
SimonDevelop committed Sep 3, 2020
2 parents 729a048 + 6c6dd18 commit ccd826c
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 21 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[![version](https://img.shields.io/badge/Version-1.0.0-brightgreen.svg)](https://github.com/SimonDevelop/sirene/releases/tag/1.0.0)
[![version](https://img.shields.io/badge/Version-1.0.1-brightgreen.svg)](https://github.com/SimonDevelop/sirene/releases/tag/1.0.1)
[![Minimum PHP Version](https://img.shields.io/badge/php-%3E%3D%207.1-8892BF.svg)](https://php.net/)
[![Github Actions PHP](https://github.com/SimonDevelop/sirene/workflows/PHP/badge.svg)](https://github.com/SimonDevelop/sirene/actions)
[![GitHub license](https://img.shields.io/badge/License-MIT-blue.svg)](https://github.com/SimonDevelop/sirene/blob/master/LICENSE)
Expand Down
44 changes: 24 additions & 20 deletions src/Sirene.php
Original file line number Diff line number Diff line change
Expand Up @@ -205,29 +205,33 @@ public function searchEtablissement(array $params, string $tri = "siren", int $p
];
$data = "";
$JWT = $this->getJWTSirene();
if (is_string($JWT) && !empty($params)) {
foreach ($params as $k => $v) {
if (array_key_exists($k, $list)) {
$data .= $list[$k].":".$v." AND ";
unset($params[$k]);
if (is_string($JWT)) {
if (!empty($params)) {
foreach ($params as $k => $v) {
if (array_key_exists($k, $list)) {
$data .= $list[$k].":".$v." AND ";
unset($params[$k]);
}
}
}
$data = urlencode(substr($data, 0, -5));
$ch = curl_init();
$paramsTri = "&debut=".$page."&nombre=".$nombre."&tri=".$tri;
curl_setopt($ch, CURLOPT_URL, $this->urlApi."/siret/?q=".$data.$paramsTri);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$headers = [
"Accept: application/json",
"Authorization: Bearer ".$JWT
];
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
$result = curl_exec($ch);
if (curl_errno($ch)) {
$data = urlencode(substr($data, 0, -5));
$ch = curl_init();
$paramsTri = "&debut=".$page."&nombre=".$nombre."&tri=".$tri;
curl_setopt($ch, CURLOPT_URL, $this->urlApi."/siret/?q=".$data.$paramsTri);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$headers = [
"Accept: application/json",
"Authorization: Bearer ".$JWT
];
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
$result = curl_exec($ch);
if (curl_errno($ch)) {
return false;
}
curl_close($ch);
return json_decode($result, true);
} else {
return false;
}
curl_close($ch);
return json_decode($result, true);
} else {
return $JWT;
}
Expand Down

0 comments on commit ccd826c

Please sign in to comment.