Copy-paste ready examples to integrate the API in your application.
<?php
class Api {
public $api_url = 'https://www.smmexchange.com/api.php';
public $api_key = '';
public function __construct($api_key) { $this->api_key = $api_key; }
public function order($data) {
return json_decode($this->connect(array_merge(['key' => $this->api_key, 'action' => 'add'], $data)));
}
public function status($order_id) {
return json_decode($this->connect(['key' => $this->api_key, 'action' => 'status', 'order' => $order_id]));
}
public function services() {
return json_decode($this->connect(['key' => $this->api_key, 'action' => 'services']));
}
public function balance() {
return json_decode($this->connect(['key' => $this->api_key, 'action' => 'balance']));
}
private function connect($post) {
$ch = curl_init($this->api_url);
curl_setopt_array($ch, [
CURLOPT_RETURNTRANSFER => 1,
CURLOPT_POST => 1,
CURLOPT_POSTFIELDS => http_build_query($post),
CURLOPT_SSL_VERIFYPEER => 0,
CURLOPT_FOLLOWLOCATION => true,
]);
$result = curl_exec($ch);
curl_close($ch);
return $result;
}
}
$api = new Api('YOUR_API_KEY');
$services = $api->services();
$order = $api->order(['service' => 1, 'link' => 'https://example.com/page', 'quantity' => 100]);
$status = $api->status($order->order);
$balance = $api->balance();
?>
import requests
class Api:
def __init__(self, api_url, api_key):
self.api_url = api_url
self.api_key = api_key
def order(self, data):
return self.connect({**{'key': self.api_key, 'action': 'add'}, **data})
def status(self, order_id):
return self.connect({'key': self.api_key, 'action': 'status', 'order': order_id})
def services(self):
return self.connect({'key': self.api_key, 'action': 'services'})
def balance(self):
return self.connect({'key': self.api_key, 'action': 'balance'})
def connect(self, data):
return requests.post(self.api_url, data=data).json()
api = Api('https://www.smmexchange.com/api.php', 'YOUR_API_KEY')
services = api.services()
order = api.order({'service': 1, 'link': 'https://example.com/page', 'quantity': 100})
status = api.status(12345)
balance = api.balance()