<?php
// Fetch and display the service list from the SMM Station API
// Step 1: Make the API request
$response = wp_remote_post('https://smmstation.com/api/v2', array(
'body' => array(
'key' => '4ba9a5ef8b97a9754b901a689ce3abe1', // Replace 'Your_API_Key' with your actual API key
'action' => 'services',
),
'headers' => array(
'Content-Type' => 'application/json',
),
));
// Step 2: Check for errors and process the response
if (is_wp_error($response)) {
$error_message = $response->get_error_message();
echo "Something went wrong: $error_message";
} else {
// Step 3: Decode the JSON response
$body = wp_remote_retrieve_body($response);
$data = json_decode($body);
// Step 4: Display the service list
if (!empty($data)) {
echo "<ul>";
foreach ($data as $service) {
echo "<li>";
echo "Service ID: " . $service->service . "<br>";
echo "Name: " . $service->name . "<br>";
echo "Type: " . $service->type . "<br>";
echo "Category: " . $service->category . "<br>";
echo "Rate: $" . $service->rate . "<br>";
echo "Minimum: " . $service->min . "<br>";
echo "Maximum: " . $service->max . "<br>";
echo "Refill: " . ($service->refill ? 'Yes' : 'No') . "<br>";
echo "Cancel: " . ($service->cancel ? 'Yes' : 'No') . "<br>";
echo "</li>";
}
echo "</ul>";
} else {
echo "No services found.";
}
}
?>