-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathJSONa.php
More file actions
70 lines (59 loc) · 1.71 KB
/
JSONa.php
File metadata and controls
70 lines (59 loc) · 1.71 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
65
66
67
68
69
70
<?php
// include our wordpress functions
// change relative path to find your WP dir
define('WP_USE_THEMES', false);
require('./wp-blog-header.php');
header('Content-type: application/json');
// set header for json mime type
class Error {
public $teachingID;
public $title;
public $date;
public $url;
public $catagories;
public $author;
public $extra;
public function __construct(){
$teachingID = '';
$title = '';
$teachingDate = '';
$url = '';
$catagories = '';
$author = '';
$extra = '';
}
public function toJSON(){
$json = array(
'teachingId' => $this->teachingID,
'title' => $this->title,
'teachingDate' => $this->teachingDate,
'url' => $this->url,
'catagories' => $this->catagories,
'author' => $this->author,
'extra' => $this->extra,
);
return json_encode($json);
}
}
// get latest single post
// exclude a category (#5)
$args = array( 'numberposts' => 500);
$myresponse = get_posts( $args);
$stack = array();
foreach ($myresponse as $res): setup_postdata($res);
$keys = get_post_custom($res->ID);
$keys = $keys['enclosure']['0'];
$help = explode('/', trim($keys));
$help = explode('.mp3', trim($help['6']));
$final = $help['0'];
$temp3 = "http://repo.neoxenos.org/public/audio/podcasts/" . $final . ".mp3" ;
$teachingJson = new Error();
$teachingJson->teachingID = $final;
$teachingJson->title = $res->post_title;
$teachingJson->teachingDate = substr($res->post_date, 0, 10);
$teachingJson->author = get_the_author();
$teachingJson->url = $final. ".mp3" ;
array_push($stack, $teachingJson);
endforeach;
echo json_encode($stack);
?>