-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest.php
More file actions
64 lines (54 loc) · 1.98 KB
/
test.php
File metadata and controls
64 lines (54 loc) · 1.98 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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
<?
$call = CallAPI('GET', 'http://vvv-vallei-evenementen.nl.84-38-229-61.eftwee.nl/api/events?city=veenendaal');
function CallAPI($method, $url, $data = false)
{
$curl = curl_init();
switch ($method)
{
case "POST":
curl_setopt($curl, CURLOPT_POST, 1);
if ($data)
curl_setopt($curl, CURLOPT_POSTFIELDS, $data);
break;
case "PUT":
curl_setopt($curl, CURLOPT_PUT, 1);
break;
default:
if ($data)
$url = sprintf("%s?%s", $url, http_build_query($data));
}
// Optional Authentication:
curl_setopt($curl, CURLOPT_HTTPHEADER,array ('Access-Token: XE9e9WWjRyzDn7aW','Accept:application/json'));
curl_setopt($curl, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
curl_setopt($curl, CURLOPT_USERPWD, "username:password");
curl_setopt($curl, CURLOPT_URL, $url);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
return curl_exec($curl);
}
$decoded = json_decode($call,TRUE);
//$decoded['events'][0];
//print_r(array_keys($decoded['events'][0]));
print_r($decoded['events'][0]);
/*
//next example will recieve all messages for specific conversation
$service_url = 'http://vvv-vallei-evenementen.nl.84-38-229-61.eftwee.nl/api/events?city=veenendaal';
$curl = curl_init($service_url);
curl_setopt($curl, CURLOPT_HTTPHEADER,array ('Access-Token: XE9e9WWjRyzDn7aW','Accept:text/xml'));
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
$curl_response = curl_exec($curl);
if ($curl_response === false) {
$info = curl_getinfo($curl);
curl_close($curl);
die('error occured during curl exec. Additioanl info: ' . var_export($info));
}
curl_close($curl);
$decoded = json_decode($curl_response);
//echo $decoded->response->status;
if (isset($decoded->response->status) && $decoded->response->status == 'ERROR') {
die('error occured: ' . $decoded->response->errormessage);
}
//echo 'response ok!';
var_export($decoded->response);
*/
//print_r($decoded->response);
?>