'', 'author' => '', 'description' => '', 'published' => '', 'tags' => ''); $result = array('success' => 'false', 'data' => $data); // Only available to logged_in user if (!empty($url) && is_logged_in()) { $parsed_url = parse_url($url); if ($parsed_url && isset($parsed_url['host'])) { if (in_array($parsed_url['host'], array('slideshare.net', 'www.slideshare.net'))) { $sobject = new SlideShare(); $returned = $sobject->get_slideshow($url); if ($returned) { if (is_string($returned->Title)) { $data['title'] = $returned->Title; } if (is_string($returned->Username)) { $data['author'] = $returned->Username; } if (is_string($returned->Description)) { $data['description'] = $returned->Description; } if (is_string($returned->Created)) { $data['published'] = date("d.m.Y", strtotime($returned->Created)); } if (isset($returned->Tags->Tag) && is_array($returned->Tags->Tag)) { $data['tags'] = implode(',', $returned->Tags->Tag); } } // even if could not get data from slideshare, set type as slideshare $result['success'] = 'true'; $data['subtype'] = 'slideshare'; $result['data'] = $data; } else if (in_array($parsed_url['host'], array('youtube.com', 'www.youtube.com')) && isset($parsed_url['query'])) { $parsed_query = array(); parse_str($parsed_url['query'], $parsed_query); if (isset($parsed_query['v']) && $parsed_query['v']) { $sobject = new YouTube(); $returned = $sobject->get_video($url, $parsed_query['v']); if ($returned) { $data['title'] = $returned->{'media$group'}->{'media$title'}->{'$t'}; $data['author'] = $returned->author[0]->name->{'$t'}; $data['description'] = $returned->{'media$group'}->{'media$description'}->{'$t'}; $data['published'] = date("d.m.Y", strtotime($returned->published->{'$t'})); $data['tags'] = $returned->{'media$group'}->{'media$keywords'}->{'$t'}; } } // even if could not get video data, set type as youtube $result['success'] = 'true'; $data['subtype'] = 'youtube'; $result['data'] = $data; } else if (in_array($parsed_url['host'], array('lemill.net', 'www.lemill.net'))) { // A small hack to get subtype set to lemill $data['subtype'] = 'lemill'; $result['success'] = 'true'; $result['data'] = $data; } } } echo json_encode($result); exit; ?>