1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

Make Auto Generated Youtube

Discussion in 'PHP' started by ntie29, Mar 6, 2012.

  1. #1
    hallo fren.....i want to share my script code....i hope this usefulll

    Firstly : Use CMS wordpress, why must wordpress, because wordpress seo friendly....

    Please copy this code :
    <?php
    //gettitle
    $keys = str_replace(' ', '+' , get_the_title());
     
    //request result to youtube
    $jsonfile='http://gdata.youtube.com/feeds/api/videos?v=2&alt=jsonc&q='.$keys.'&max-results=5';
     
    //fetching data to json
    $data = json_decode(file_get_contents($jsonfile));
     
    // url video
    $video_url = $data->data->items[0]->player->default;
     
    // clean unnecessary teks
    $video_play = trim ( $video_url, "&feature=youtube_gdata_player" );
     
    // video durasi 
    $video_duration = $data->data->items[0]->duration;
     
    // conversion duration in one minutes
    $video_duration_min = round ($video_duration / 60, 2);
     
    // views video
    $video_views = $data->data->items[0]->viewCount;
     
    // get url images
    $video_code = $data->data->items[0]->id;
     
    // image1
    $video_thumb1 = 'http://i.ytimg.com/vi/'.$video_code.'/1.jpg';
     
    // image2
     
    $video_thumb2 = 'http://i.ytimg.com/vi/'.$video_code.'/2.jpg';
     
    // image3
    $video_thumb3 = 'http://i.ytimg.com/vi/'.$video_code.'/3.jpg';
     
    //video_description
    $video_desc = $data->data->items[0]->description;
    ?>
     
    <div id="video">Loading the player ...</div>
    
    <script type="text/javascript">
    jwplayer("video").setup({
    flashplayer: "/wp-content/themes/f1/js/player.swf",
    file: "<? echo $video_play;?>",
    height: 300,
    width: 605,
    wmode : "transparent",
    skin: "/chrome.zip"
    });
    </script>
    PHP:
    paste in single.php page, above <?php get_content ?>

    next, please open header.php....and find this code </head>,,,,if you have foundit
    <script type="text/javascript" src="/js/swfobject.js"></script>
    <script type="text/javascript" src="/js/jwplayer.js"></script>

    please look result........

    if you want to ask i will try to answers...thanx
     
    ntie29, Mar 6, 2012 IP