Skip to content

Commit 4d6f705

Browse files
committed
Add Gittip example
1 parent 15a121c commit 4d6f705

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

examples/gittip_send_tip.php

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
<?php
2+
require '../src/Curl.class.php';
3+
4+
5+
define('GITTIP_USERNAME', 'XXXXXXXXXX');
6+
define('GITTIP_API_KEY', 'XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX');
7+
8+
$data = array(
9+
array(
10+
'username' => 'user' . mt_rand(),
11+
'platform' => 'gittip',
12+
'amount' => '0.02',
13+
),
14+
array(
15+
'username' => 'user' . mt_rand(),
16+
'platform' => 'gittip',
17+
'amount' => '0.02',
18+
),
19+
);
20+
21+
$curl = new Curl();
22+
$curl->setHeader('Content-Type', 'application/json');
23+
$curl->setBasicAuthentication(GITTIP_API_KEY);
24+
$curl->post('https://www.gittip.com/' . GITTIP_USERNAME . '/tips.json', json_encode($data));
25+
26+
foreach ($curl->response as $tip) {
27+
echo $tip->amount . ' given to ' . $tip->username . '.' . "\n";
28+
}

0 commit comments

Comments
 (0)