Skip to content

Commit

Permalink
Fix issue with girocleta's website SSL certificate
Browse files Browse the repository at this point in the history
  • Loading branch information
Lloople committed Jul 18, 2018
1 parent b480fc7 commit b72f581
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions app/Services/StationService.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public function all()
*/
private function getStations()
{
$html = file_get_contents('http://girocleta.cat');
$html = $this->query();

$locations = preg_match_all(self::REGEX_LOCATION, $html, $matches) ? $matches[1] : [];

Expand All @@ -51,11 +51,21 @@ private function getStations()
'parkings' => $matches['parkings'][$index],
'bikes' => $matches['bikes'][$index],
'latitude' => $latitude,
'longitude' => $longitude
'longitude' => $longitude,
];
}, array_keys($locations));
}

private function query()
{
return file_get_contents('https://www.girocleta.cat', false, stream_context_create([
"ssl" => [
"verify_peer" => false,
"verify_peer_name" => false,
],
]));
}

/**
* Return stations as buttons in key - value format.
*
Expand Down Expand Up @@ -84,6 +94,7 @@ public function find($id)
* @param float $latitude
* @param float $longitude
* @param int $limit
*
* @return \Illuminate\Support\Collection
*/
public function getNearStations(float $latitude, float $longitude, int $limit = 3)
Expand Down Expand Up @@ -135,5 +146,4 @@ public function findByText($text)
return $station && $station->distance <= 4 ? $station->foundByAddress() : null;
}


}

0 comments on commit b72f581

Please sign in to comment.