Couldn't Resolve Host (cURL)

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/yde49f3d

Any 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/pCSkU6UQ

Note:[php] function u()[/php] and[php] function h() [/php]are [php]urlencode() [/php]and [php]htmlspecialchars()[/php], respectively. Thanks!

Edit: Realized I wouldn’t click the link to look at code in another tab, so here’s the code directly:

[code]

[/code] [php]<?php

$token = “SECRETTOKEN”;
$pageNumber = 0;
$continuationToken = “”;

$curl = curl_init();

curl_setopt_array($curl, array(CURLOPT_URL => “https://www.eventbriteapi.com/v3/users/me/owned_events/?token=SECRETTOKEN”,
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']; ?>
Event ID Event Name Location Description Link Time Date Add Event View Attendees
<?php echo($event_id);?>[/php][code] <?php echo ($event_name);?> <?php echo ($location);?> <?php echo ($description);?> <?php echo ($link);?> <?php echo ($time);?> <?php echo ($date);?> [/php][/code]

Probably a stupid comment, but why are you defining $token and then doing this,

[php]curl_setopt_array($curl, array(CURLOPT_URL => “https://www.eventbriteapi.com/v3/users/me/owned_events/?token=SECRETTOKEN”[/php]

And not
[php]curl_setopt_array($curl, array(CURLOPT_URL => “https://www.eventbriteapi.com/v3/users/me/owned_events/?token=$token”[/php]

Sponsor our Newsletter | Privacy Policy | Terms of Service