-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathindex.php
66 lines (55 loc) · 1.69 KB
/
index.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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
<?php
/*
* Here are some example use cases.
*
*/
require_once 'src/ApiConsumer/Consumer.php';
//require_once 'vendor/autoload.php'; // if using Composer autoloader and psr-0
use ApiConsumer\Consumer;
/**
* The example below uses the API at Active.com to query "Running" activities in
* Florida with a start date within the next month that meet the query string of
* "ultra marathon". It will return a result set of 25 records as set.
*
* @author Adam Culp http://www.geekyboy.com
*/
$apiConsumer = new Consumer();
$url = 'http://api.amp.active.com/search?';
$meta = 'meta:channel=Running+meta:startDate:daterange:today..' . date('Y-m-d', strtotime('next month'));
$params = array(
'k' => 'ultra+marathon',
'v' => 'json',
'l' => 'Florida',
'r' => '25',
's' => 'date_asc',
'api_key' => '{Add API Key Here}',
'm' => $meta
);
$options = array(
CURLOPT_HEADER => 0,
CURLOPT_RETURNTRANSFER => 1,
CURLOPT_PORT => 8080
);
$apiConsumer->setParams($params);
$apiConsumer->setOptions($options);
$apiConsumer->setResponseType('json');
$apiConsumer->setCallType('get');
$apiConsumer->setUrl($url);
$result = $apiConsumer->doApiCall();
?>
<!DOCTYPE html>
<html>
<head>
<title>API Consumer Example</title>
</head>
<body>
<h1>API Consumer Example (output parsed JSON result array)</h1>
<div style="width:960px;">
<pre>
<?php foreach ($result as $key => $value): ?>
<strong><?php echo $key; ?>:</strong> <?php echo $value; ?><br />
<?php endforeach; ?>
</pre>
</div>
</body>
</html>