Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- /*
- Plugin Name: Video Poster
- Version: 0.1
- Description: Automatically make new posts based on YouTube feeds.
- */
- register_activation_hook(__FILE__, 'video_poster_activation');
- add_action('video_poster_event', 'do_video_post');
- function video_poster_activation() {
- wp_schedule_event(time(), 'hourly', 'video_poster_event');
- }
- function do_video_post() {
- //yt_user("thebeats");
- //use the YouTube id in a meta custom field to check if already posted?
- }
- function get_feed($feed){
- $ch = curl_init();
- $timeout = 0;
- curl_setopt ($ch, CURLOPT_URL, $feed);
- curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
- curl_setopt ($ch, CURLOPT_CONNECTTIMEOUT, $timeout);
- $xml = curl_exec($ch);
- curl_close($ch);
- return $xml;
- }
- function yt_user($user){
- $feed = "http://gdata.youtube.com/feeds/api/users/".$user."/uploads";
- $xml = get_feed($feed);
- preg_match_all("/<media\:title type='plain'>(.+?)<\/media\:title>/",$xml,$titles);
- preg_match_all("/\/v\/(.+?)\&/i",$xml,$ids);
- array_shift($titles);
- array_shift($ids);
- $total = count($titles[0]);
- //for($i = 0; $i<$total; $i++){
- //echo "<b>".$titles[0][$i]."</b><br/>httpv://youtube.com/watch?v=".$ids[0][$i]."<br><br>";
- //}
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment