-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.php
More file actions
47 lines (34 loc) · 1.06 KB
/
index.php
File metadata and controls
47 lines (34 loc) · 1.06 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
<?php
require_once('vendor/autoload.php');
if (!class_exists('Guzzle')) {
\Guzzle\Http\StaticClient::mount();
}
EasyRdf_Namespace::set('schema', 'http://schema.org/');
$guzzleOptions = array(
'headers' => array(
'Accept' => 'text/plain',
'User-Agent' => 'code4lib_ld_preconf_demo'
)
);
$uri = 'http://www.worldcat.org/oclc/82671871';
try {
$response = \Guzzle::get($uri, $guzzleOptions);
$graph = new EasyRdf_Graph();
$graph->parse($response->getBody(true));
$bib = $graph->resource($uri);
print $bib->get('schema:name')->getValue() . "\n";
foreach ($bib->all('schema:author') as $author) {
print $author->get('schema:name') . "\n";
}
foreach ($bib->all('schema:creator') as $creator) {
print $creator->get('schema:name') . "\n";
}
foreach ($bib->all('schema:about') as $subject) {
print $subject->get('schema:name') . "\n";
}
foreach ($bib->all('schema:description') as $description) {
print $description . "\n";
}
} catch (\Guzzle\Http\Exception\BadResponseException $error) {
return 'Whoops I did not get a successful HTTP response';
}