mirror of
https://github.com/php-curl-class/php-curl-class.git
synced 2026-08-18 20:11:45 +00:00
31 lines
735 B
PHP
31 lines
735 B
PHP
<?php
|
|
|
|
require __DIR__ . '/../vendor/autoload.php';
|
|
|
|
use Curl\Curl;
|
|
|
|
const GRATIPAY_USERNAME = 'XXXXXXXXXX';
|
|
const GRATIPAY_API_KEY = 'XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX';
|
|
|
|
$data = [
|
|
[
|
|
'username' => 'user' . mt_rand(),
|
|
'platform' => 'gratipay',
|
|
'amount' => '0.02',
|
|
],
|
|
[
|
|
'username' => 'user' . mt_rand(),
|
|
'platform' => 'gratipay',
|
|
'amount' => '0.02',
|
|
],
|
|
];
|
|
|
|
$curl = new Curl();
|
|
$curl->setHeader('Content-Type', 'application/json');
|
|
$curl->setBasicAuthentication(GRATIPAY_API_KEY);
|
|
$curl->post('https://gratipay.com/' . GRATIPAY_USERNAME . '/tips.json', $data);
|
|
|
|
foreach ($curl->response as $tip) {
|
|
echo $tip->amount . ' given to ' . $tip->username . '.' . "\n";
|
|
}
|