phpwordpressapieventbrite

PHP code to Eventbrite API returning error status_code":404


I am trying to get all events of an organization by token and organisation ID but I am getting

{"status_code":404,"error_description":"The path you requested does not exist.","error":"NOT_FOUND"}

Here is my PHP code, any help would be appreciated.

<?php
//error_reporting(E_ALL);
ini_set('display_errors', '1');
$token = 'XYZ123456XYZ';
$url = 'https://www.eventbriteapi.com/v3/organizations/123456789/events=' . $token;

// Initialize cURL
$ch = curl_init();

// Set the cURL options
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);

// Execute the cURL request and get the response
$response = curl_exec($ch);

// Print the raw response to the console
echo '<pre>';
print_r($response);
echo '</pre>';

// Close the cURL session
curl_close($ch);

// Parse the JSON response
$events = json_decode($response, true);

// Check for errors
if (isset($events['error'])) {
    echo 'Error: ' . $events['error_description'];
} else {
    // Loop through the events and display their information
    foreach ($events['events'] as $event) {
        echo '<h2>' . $event['name']['text'] . '</h2>';
        echo '<p>' . $event['description']['text'] . '</p>';
        echo '<p>' . $event['start']['local'] . '</p>';
        echo '<p>' . $event['end']['local'] . '</p>';
        echo '<p>' . $event['venue']['name'] . '</p>';
        echo '<hr>';
    }
}

I have tried changing the end point URL values , tried with and without organisation IDS but nothing seems to be work. It should show all event name, description , start time etc.


Solution

  • I went through the documentation some more and found that the link I was using was deprecated, I am leaving the answer here for others to find it easily.

    this is the link to get private token

    https://www.eventbrite.com/platform/docs/authentication#get-a-private-token

    https://www.eventbrite.com/platform/api-keys

    <?
     //error_reporting(E_ALL);
    //ini_set('display_errors', '1');
    
    $token = 'enterurtokenhere';
    $url = 'https://www.eventbriteapi.com/v3/organizations/{enteruridhere}/events/?status=live';
    
    // Initialize cURL
    $ch = curl_init();
    
    // Set the cURL options
    curl_setopt($ch, CURLOPT_URL, $url);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    curl_setopt($ch, CURLOPT_HTTPHEADER, array(
        'Authorization: Bearer ' . $token
    ));
    
    // Execute the cURL request and get the response
    $response = curl_exec($ch);
    
    // Print the raw response to the console
    echo '<pre>';
    print_r($response);
    echo '</pre>';
    
    // Close the cURL session
    curl_close($ch);
    
    // Parse the JSON response
    $events = json_decode($response, true);
    
    // Check for errors
    if (isset($events['error'])) {
        echo 'Error: ' . $events['error_description'];
    } else {
        // Loop through the events and display their information
        foreach ($events['events'] as $event) {
            echo '<h2>' . $event['name']['text'] . '</h2>';
            echo '<p>' . $event['description']['text'] . '</p>';
            echo '<p>' . $event['start']['local'] . '</p>';
            echo '<p>' . $event['end']['local'] . '</p>';
            echo '<p>' . $event['venue']['name'] . '</p>';
            echo '<hr>';
        }
    }
    ?>