forked from MalMen/PHP-Monero
-
Notifications
You must be signed in to change notification settings - Fork 0
/
example.php
40 lines (30 loc) · 1.12 KB
/
example.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
<?php
/**
* Example code
*
* @filesource
*/
/** You need to create a MySQLi instance first */
$mysqli = new mysqli('host','user','pass','database');
/** The Monero Interface takes this MySQLi instance as an argument */
$MoneroAPI = new \includes\PHP_Monero($mysqli);
/** This will return an array with a new payment address */
$payment_address = $MoneroAPI->create_payment_address();
/** I wonder if it worked */
if ($payment_address) {
echo "transfer 3 $payment_address[openalias] 5 $payment_address[payment_id]";
echo '<br />';
} else {
echo 'Handle the error. <br />';
}
/** This will send a transfer for 5 Moneroj to the database for later processing */
$transfer = $MoneroAPI->transfer('address', 5);
/** Did that work? *//
if (!$transfer) {
echo 'Didn\'t think so. "Address" is not a valid address :P <br />';
} else {
echo ($transfer["amount"]/12) . " XMR will be sent to $transfer[address] <br />";
}
/** The below methods should be added to your Cron Jobs */
$MoneroAPI->client_receive(); // procceing receipts
$MoneroAPI->client_transfer(); // processing transfers