function TPConnectEntry($params) { if (!array_key_exists('post_xid', $params)) { if (!array_key_exists('blog_xid', $params) && !array_key_exists('permalink', $params)) { debug("[TPConnectEntry::TPConnectEntry] Either a post_xid OR blog_xid and permalink are required."); } } if (array_key_exists('entry_id', $params)) { $this->entry_id = $params['entry_id']; } if (array_key_exists('content', $params)) { $this->content = $params['content']; } if (array_key_exists('permalink', $params)) { $this->permalink = $params['permalink']; } if (array_key_exists('permalink', $params) && array_key_exists('blog_xid', $params)) { $json = '{"permalinkUrl":"' . $params['permalink'] . '"}'; $post_url = get_tpconnect_external_assets_api_url($params['blog_xid']); $events = post_json($post_url, $json); $this->blog_xid = $params['blog_xid']; $this->xid = $events->asset->urlId; } $this->tp_comment_listing = array(); }
function Post($params) { // otherwise, use the param keys to insert the author data. $keys = array('xid', 'blog_xid', 'fb_id', 'permalink', 'content', 'site_id'); foreach ($keys as $key) { if (array_key_exists($key, $params)) { $this->{$key} = $params[$key]; } else { $this->{$key} = 0; } } if ($this->blog_xid and $this->permalink) { $json = '{"permalinkUrl":"' . $this->permalink . '"}'; $post_url = get_tpconnect_external_assets_api_url($this->blog_xid); $events = post_json($post_url, $json); $this->xid = $events->asset->urlId; debug("[Post::Post] this XID = " . $this->xid); } $this->comment_listing = array(); if ($this->content) { $this->content = urldecode($this->content); } if (!array_key_exists('READ_ONLY', $params)) { if (array_key_exists('fb_prefix', $params) && array_key_exists('xid', $params)) { $this->fb_id = $params['fb_prefix'] . $params['xid']; } $this->update_post_content(); // IF we have a parent site, we should start a FB session. if ($this->site_id) { $this->facebook = start_fb_session(get_fb_api_key($this->site_id), get_fb_api_secret($this->site_id)); } } }
function lms_enroll_user($user_lmsid, $course_lmsid, $accesskey) { global $apiurl; $data = json_encode(array("enrollment" => array("user_id" => $user_lmsid, "type" => "StudentEnrollment", "enrollment_state" => "active", "notify" => "0"))); return post_json($apiurl . "/courses/" . $course_lmsid . "/enrollments", $data, $accesskey); }