function TPCommentListing($entry_xid) { $tp_comments = array(); $events = pull_json(get_comments_api_url($entry_xid)); $i = 0; $param = array(); foreach ($events->{'entries'} as $comment) { $param['xid'] = $comment->urlId; $param['json'] = $comment; $this->tp_comments[$i] = new Comment("TypePad", $param); $i++; } }
function Favorite($params) { if (!array_key_exists('xid', $params) and !array_key_exists('json', $params)) { debug("[Favorite::Favorite] Favorite constructor requires an XID or JSON."); return; } if (!array_key_exists('json', $params)) { $params['json'] = pull_json(get_favorite_api_url($params['xid'])); } $this->author = new Author(array('json' => $params['json']->author)); $this->xid = $params['json']->urlId; /* $date = new DateTime($favorite_json->published); $this->timestamp = print_timestamp($date); */ // FOR PHP 5.1.6 COMPATIBILITY. $this->timestamp = new TPDate($params['json']->published); }
function Author($params) { // Allow creationg of empty Author to allow // other services to override it. if (!array_key_exists('xid', $params) && !array_key_exists('json', $params) && !array_key_exists('username', $params)) { return; } $identifier = array(); // otherwise, remember the unique identifier for this user. if (array_key_exists('xid', $params)) { $identifier['value'] = $params['xid']; $identifier['source'] = 'xid'; } else { if (array_key_exists('json', $params)) { $identfier['value'] = $params['json']->urlId; $identifier['source'] = 'json'; } else { $identifier['value'] = $params['username']; $identifier['source'] = 'username'; } } if (!array_key_exists('json', $params)) { $params['json'] = pull_json(get_author_api_url($identifier['value'])); } // in case the API request couldn't find that user, return. if (!$params['json']) { debug("[Author::Author] The user identified by " . $identifier['source'] . "'" . $identifier['value'] . "' was not found."); return; } // At this point, we should have valid JSON. $this->xid = $params['json']->urlId; $this->display_name = $params['json']->displayName; $this->profile_url = $params['json']->profilePageUrl; $this->username = $params['json']->preferredUsername; $this->avatar = get_resized_avatar($params['json'], 35); }
function EntryListing($params) { // XID is required. if (!array_key_exists('xid', $params)) { debug("[EntryListing::EntryListing] Blog XID is required as an argument to the constructor."); return; } $this->entry_listing = array(); if (!array_key_exists('page_number', $params)) { $params['page_number'] = 1; } if (!array_key_exists('posts_per_page', $params)) { $params['posts_per_page'] = POSTS_PER_PAGE; } $events = pull_json(get_entries_api_url($params)); $i = 0; foreach ($events->{'entries'} as $entry) { $this->entry_array[$i] = new Entry(array('xid' => $entry->urlId, 'json' => $entry)); $i++; } $this->total_entry_count = $events->totalResults; $this->page_number = $params['page_number']; $this->posts_per_page = $params['posts_per_page']; }
function Entry($params) { if (!array_key_exists('xid', $params)) { debug("[Entry::Entry] The entry XID is required in the constructor..."); return; } if (!array_key_exists('json', $params)) { $params['json'] = pull_json(get_entry_api_url($params['xid'])); } // otherwise, ($type == 'json'), format is ready to parse. $this->title = get_entry_title($params['json']); $this->body = $params['json']->content; $this->permalink = $params['json']->permalinkUrl; $this->thumbnail = get_first_thumbnail($params['json']->embeddedImageLinks); $this->xid = $params['json']->urlId; $this->author = new Author(array('xid' => $params['json']->author->urlId, 'json' => $params['json']->author)); // GETTING RID OF DateTime for PHP 5.1.6 compatibility // $date = new DateTime($entry_json->published); // $this->timestamp = print_timestamp($date); $this->timestamp = new TPDate($params['json']->published); }
function TPCommentListing($params) { if (!array_key_exists('xid', $params)) { debug("[TPCommentListing::TPCommentListing] Expected parameter 'xid' in the constructor."); return; } $this->post_xid = $params['xid']; $this->comment_listing = array(); $events = pull_json(get_comments_api_url($params['xid'])); $i = 0; foreach ($events->{'entries'} as $comment) { $this->comment_array[$i] = new Comment(array('xid' => $comment->urlId, 'json' => $comment)); $i++; } }