40 lines
1021 B
PHP
40 lines
1021 B
PHP
<?php
|
|
|
|
class WhopApi
|
|
{
|
|
private $apiKey;
|
|
private $appId;
|
|
private $baseUrl = 'https://api.whop.com/api/v2';
|
|
|
|
public function __construct($apiKey, $appId)
|
|
{
|
|
$this->apiKey = $apiKey;
|
|
$this->appId = $appId;
|
|
}
|
|
|
|
public function getMembers()
|
|
{
|
|
$url = $this->baseUrl . '/members';
|
|
|
|
$ch = curl_init();
|
|
curl_setopt($ch, CURLOPT_URL, $url);
|
|
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
|
curl_setopt($ch, CURLOPT_HTTPHEADER, [
|
|
'Authorization: Bearer ' . $this->apiKey,
|
|
'Accept: application/json'
|
|
]);
|
|
|
|
$response = curl_exec($ch);
|
|
$httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
|
|
curl_close($ch);
|
|
|
|
if ($httpCode >= 200 && $httpCode < 300) {
|
|
return json_decode($response, true);
|
|
} else {
|
|
// Log or handle error appropriately
|
|
error_log("Whop API Error: HTTP " . $httpCode . " - " . $response);
|
|
return false;
|
|
}
|
|
}
|
|
}
|