Hello. I'm fairly new to PHP, and unfortunately the specificity of my problem means I have to just ask about it: I am using Eventbrite's API and cURL, pulling data into a table (formatted through DataTables) and I am getting this "Couldn't resolve host" error, for approximately the first 11 pages, at which point I am presented with the data formatted as expected.
Here is the result:
https://tinyurl.com/yde49f3dAny help is much appreciated, this one has me beat-down and put my junior-level programmer ego in check!
And here is the back-end code:
https://pastebin.com/pCSkU6UQNote: function u() and function h() are urlencode() and htmlspecialchars(), respectively. Thanks!
Edit: Realized I wouldn't click the link to look at code in another tab, so here's the code directly:
<table id="events" class="display compact" width="100%">
<thead>
<tr>
<th>Event ID</th>
<th>Event Name</th>
<th>Location</th>
<th>Description</th>
<th>Link</th>
<th>Time</th>
<th>Date</th>
<th>Add Event</th>
<th>View Attendees</th>
</tr>
</thead>
<tbody>
<?php
$token = "IPUTMYAPITOKENINTOAPUBLICPOSTONTHEINTERNET";
$pageNumber = 0;
$continuationToken = "";
$curl = curl_init();
curl_setopt_array($curl, array(CURLOPT_URL => "
https://www.eventbriteapi.com/v3/users/me/owned_events/?token=IPUTMYAPITOKENINTOAPUBLICPOSTONTHEINTERNET",CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET"
));
$urlloop = u(h('
https://www.eventbriteapi.com/v3/users/me/owned_events/?'));$response = curl_exec($curl);
$err = curl_error($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
// Stores the json response data in an array
$array = json_decode($response, true);
}
?>
<?php
for($i = 0; $i < $array["pagination"]["page_count"]; $i++) {
if($array["pagination"]["has_more_items"] === true) {
for($j = 0; $j < $array["pagination"]["page_size"]; $j++) {
$continuationToken = $array["pagination"]["continuation"];
$newurl = '"';
$newurl .= $urlloop;
$newurl .= "continuation=";
$newurl .= $continuationToken;
$newurl .= "&token=";
$newurl .= $token;
$newurl .= "&page=";
$newurl .= $pageNumber;
$newurl .= '"';
curl_setopt_array($curl, array(CURLOPT_URL => $newurl,
CURLOPT_CUSTOMREQUEST => "GET"));
$response = curl_exec($curl);
$err = curl_error($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
$array = json_decode($response, true);
}
$event_id = $array['events'][$j]['id'];
$event_name = $array['events'][$j]['name']['text'];
$location = $array['events'][$j]['venue_id'];
$description = $array['events'][$j]['description']['text'];
$link = $array['events'][$j]['url'];
$time = $array['events'][$j]['start']['local'];
$date = $array['events'][$j]['start']['local'];
?>
<tr><td><?php echo($event_id);?></td>
<td><?php echo ($event_name);?></td>
<td><?php echo ($location);?></td>
<td><?php echo ($description);?></td>
<td><?php echo ($link);?></td>
<td><?php echo ($time);?></td>
<td><?php echo ($date);?></td>
<td><a href=<?php echo 'add-events.php?id=' . $event_id . '&name=' . h(u($event_name)) ?>><button class="btn btn-default btn-md">Add Event</button></a></td>
<td><a href=<?php echo 'show-attendees.php?id=' . $event_id . '&name=' . h(u($event_name)) ?>><button class="btn btn-default btn-md">View Attendees</button></a></td></tr>
<?php
}
}
$pageNumber++;
}
?>
</tbody>
</table>
<script>
$('#events').dataTable( {
"autoWidth": false,
"columns": [
{ "width": "5%" },
{ "width": "10%" },
{ "width": "5%" },
{ "width": "75%" },
{ "width": "5%" },
]
} );
</script>
<?php curl_close($curl); ?>
<?php
include_once('footer.php');
?>
</body>