3 * Table Definition for cash_costing_map
5 require_once 'DB/DataObject.php';
8 class Pman_Reddit_DataObjects_Reddit_livefeed extends DB_DataObject
11 /* the code below is auto generated do not remove the above tag */
13 public $__table = 'reddit_livefeed'; // table name
14 public $id; // int(11) not_null primary_key auto_increment
15 public $body; // string(254) not_null
16 public $uid; // int(11) not_null
17 public $created_dt; // int(11) not_null
18 public $embeds; // int(11) not_null
19 public $body_html; // int(11) not_null
23 /* the code above is auto generated do not remove the tag below */
26 function fetchFrom($from='')
29 $base = "https://www.reddit.com/live/tnc30xhiiqom.json";
30 $after = strlen($from) ? ('after=LiveUpdate_' . $from) : '';
31 $count = strlen($from) ? 'count=75' : '';
32 $url = $base . '?' . implode('&', array($after, $count));
36 $raw = file_get_contents($url);
38 $data = json_decode($raw);
39 if (!count($data->data->children)) {
43 echo date('Y-m-d H:i:s', $data->data->children[0]->data->created) . "\n";
58 embeds: array(url / width / height)
67 foreach($data->data->children as $child) {
70 $ch->body_html = html_entity_decode($ch->body_html);
71 $ch->prev_uid = $last;
72 $ch->created_dt = date('Y-m-d H:i:s', $ch->created);
73 $ch->embeds = json_encode($ch->embeds);
78 $x = DB_DataObject::factory('reddit_livefeed');
79 if ($x->get('uid', $ch['uid'])) {
93 // if we did not add any....??
94 // look for the oldest???
102 $r = json_decode($this->embeds);
103 return $r[0]->height;
107 $r = json_decode($this->embeds);
113 $r = json_decode($this->embeds);
117 function fetchEmbed()
120 $r = json_decode($this->embeds);
122 foreach($r as $i=>$em) {
123 //$file = /home/reddit/ date('Y/m/d', strtotime($this->created_dt . " - 8 HOURS")) . "/" . $this->uid . '.' . $i . ".pdf"
124 if (file_exist)($file) {
127 $dir = dirname($file);
128 if (!file_exist($dir)) {
129 mkdir($dir,660, true);
131 $url = http://redit.......
132 $cmd = "/usr/bin/wkhtmltopdf $url $file";