Skip to content

Commit

Permalink
Switch to using cURL to fetch data
Browse files Browse the repository at this point in the history
Toward #72.
  • Loading branch information
waldoj committed Sep 16, 2019
1 parent 94baaf8 commit b942a34
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion business.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
<?php

function get_content($url)
{
$ch = curl_init();
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_URL, $URL);
$data = curl_exec($ch);
curl_close($ch);
return $data;
}

/*
* If no business ID has been passed in the URL
*/
Expand All @@ -24,7 +34,7 @@
* Query our own API
*/
$api_url = 'https://vabusinesses.org/api/business/' . $id;
$business_json = get_file_contents($api_url);
$business_json = get_content($api_url);

$business = json_decode($business_json);
if ($business === FALSE)
Expand Down

0 comments on commit b942a34

Please sign in to comment.