Documentazione API
Link
https://mrpopular.net/api/v2.php
Richieste
POST / GET / JSON
Risposte
JSON
Autorizzazione
username
password
Scopri il bilancio
action = balance
currency = EUR
{"balance":123.456}
Scopri lo stato dell’ordine
action = status
order = (numero dell’ordine)
{"order":{"status":"2","completed":"0","quantity":"250","date":"2018-09-27 17:34:49"}}
Ottieni la lista dei servizi
action = service
{"service":{"1":{"social_network":"Facebook","service":"page likes","quality":"medium quality","id":"1","price":0.0149,"currency":"EUR","min":"100"},...}}
Stati dell'ordine
0 : in esecuzione, non ci sono statistiche
1 : in esecuzione, ci sono statistiche
2 : eseguito
3 : errore
4 : in lista d'attesa
5 : restituito
Ordine nuovo
action = order
service = ((ID servizi)
quantity = quantità
option
comment
link = link
{"order":"142058"}
Errori
{"errorcode":1} USERNAME o PASSWORD non è inviato
{"errorcode":2} ACTION non è inviato
{"errorcode":3} Valuta selezionata non è disponibile
{"errorcode":4} Il umero dell’ordinazione non è inviato
{"errorcode":5} Il numero dell’ordinazione non è valido
{"errorcode":6} SERVICE non è inviato
{"errorcode":7} La quantità non è inviata
{"errorcode":8} Il link non è inviato
{"errorcode":9} Non c'è abbastanza denaro nel bilancio
{"errorcode":10} La quantità è sotto il minimo
Esempio del codice php
class Api
{
// impostazioni
public $api_url = 'https://mrpopular.net/api/v2.php'; // link per API
public $username = ''; //il tuo username
public $password = ''; //la tua password
public $currency = 'EUR';
public function order($data) { // aggiungi un’ordine nuovo
$post = array_merge(array(
'username' => $this->username,
'password' => $this->password,
'action' => 'order'
), $data);
return json_decode($this->connect($post));
}
public function status($order) { // ottieni lo stato dell’ordine
return json_decode($this->connect(array(
'username' => $this->username,
'password' => $this->password,
'action' => 'status',
'order' => $order
)));
}
public function service() { // ottieni la lista dei servizi
return json_decode($this->connect(array(
'username' => $this->username,
'password' => $this->password,
'action' => 'service',
)));
}
public function balance() { // ottieni il bilancio
return json_decode($this->connect(array(
'username' => $this->username,
'password' => $this->password,
'action' => 'balance',
)));
}
function connect($post) {
$_post = Array();
if (is_array($post)) {
foreach ($post 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)) {
curl_setopt($ch, CURLOPT_POSTFIELDS, join('&', $_post));
}
curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/4.0 (compatible; MSIE 5.01; Windows NT 5.0)');
$result = curl_exec($ch);
if (curl_errno($ch) != 0 && empty($result)) {
$result = false;
}
curl_close($ch);
return $result;
}
}
// stiamo lanciando API
$api = new Api();
// controlla il bilancio
/*$balance = $api->balance();
print_r($balance);*/
// ordine nuovo
/*$order = $api->order(array(
'service' => 462,
'quantity' => $qnty,
'link' => $src
));
print_r($order);*/
// stato dell’ordine
/*$status = $api->status(12232);
print_r($status);*/
// lista dei servizi
/*$service = $api->service();
print_r($service);*/