forked from unholybl00d/php-api-class
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexample.php
More file actions
44 lines (34 loc) · 1.37 KB
/
example.php
File metadata and controls
44 lines (34 loc) · 1.37 KB
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
41
42
43
44
<?php
require_once('MxitAPI.php');
try {
$key = 'f00df00df00df00df00df00df00df00d';
$secret = 'f00df00df00df00df00df00df00df00d';
$api = new MxitAPI($key, $secret);
if (isset($_GET) && isset($_GET['code'])) {
$api->get_user_token($_GET['code'], 'http://www.example.com');
// Get Contacts
$contacts = $api->get_contact_list('@Apps', 0, 2);
print_r($contacts);
// Update Status
echo "Status update ";
$api->set_status('insert status here...');
echo ($api->http_status == 200) ? 'successful' : 'failed';
echo "<br />";
// Set Avatar
echo "Set avatar ";
$avatar = file_get_contents('/Users/ashley/Pictures/goblin.jpg');
$avatar = base64_encode($avatar);
$api->set_avatar($avatar);
echo ($api->http_status == 200) ? 'successful' : 'failed';
echo "<br />";
} elseif (isset($_GET) && isset($_GET['error']) && isset($_GET['error_description'])) {
echo "<h2>There was an error requesting access from the API</h2>";
echo '<strong>Error:</strong> '. $_GET['error'] .'<br />';
echo '<strong>Error Description:</string> '. $_GET['error_description'] .'<br />';
} else {
$api->request_access('http://www.example.com', 'graph/read status/write avatar/write');
}
} catch (Exception $e) {
echo $e->getMessage();
}
?>