api_key = $api_key; } /** Add a new order */ public function addOrder($data) { $post = array_merge(['key' => $this->api_key, 'action' => 'add'], $data); return json_decode((string)$this->connect($post)); } /** Get the status of a single order */ public function getOrderStatus($order_id) { return json_decode( $this->connect([ 'key' => $this->api_key, 'action' => 'status', 'order' => $order_id ]) ); } /** Get the status of multiple orders */ public function getMultiStatus($order_ids) { return json_decode( $this->connect([ 'key' => $this->api_key, 'action' => 'status', 'orders' => implode(",", (array)$order_ids) ]) ); } /** Get a list of all services */ public function getServices() { return json_decode( $this->connect([ 'key' => $this->api_key, 'action' => 'services', ]) ); } /** Get the user's balance */ public function getBalance() { return json_decode( $this->connect([ 'key' => $this->api_key, 'action' => 'balance', ]) ); } /** A private function to handle the cURL connection */ private function connect($post_fields) { // ... (The cURL connection logic remains the same as your example) ... $_post = []; if (is_array($post_fields)) { foreach ($post_fields as $name => $value) { $_post[] = $name . '=' . urlencode($value); } } $ch = curl_init($this->api_url); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_HEADER, 0); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0); curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); if (is_array($post_fields)) { curl_setopt($ch, CURLOPT_POSTFIELDS, join('&', $_post)); } curl_setopt($ch, CURLOPT_USERAGENT, 'SmmAtto/1.0'); // يمكنك تغيير هذا ليعكس اسم موقعك $result = curl_exec($ch); if (curl_errno($ch) != 0 && empty($result)) { $result = false; } curl_close($ch); return $result; } }