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:
    1. <?php
    2. //gettitle
    3. $keys = str_replace(' ', '+' , get_the_title());
    4.  
    5. //request result to youtube
    6. $jsonfile='http://gdata.youtube.com/feeds/api/videos?v=2&alt=jsonc&q='.$keys.'&max-results=5';
    7.  
    8. //fetching data to json
    9. $data = json_decode(file_get_contents($jsonfile));
    10.  
    11. // url video
    12. $video_url = $data->data->items[0]->player->default;
    13.  
    14. // clean unnecessary teks
    15. $video_play = trim ( $video_url, "&feature=youtube_gdata_player" );
    16.  
    17. // video durasi
    18. $video_duration = $data->data->items[0]->duration;
    19.  
    20. // conversion duration in one minutes
    21. $video_duration_min = round ($video_duration / 60, 2);
    22.  
    23. // views video
    24. $video_views = $data->data->items[0]->viewCount;
    25.  
    26. // get url images
    27. $video_code = $data->data->items[0]->id;
    28.  
    29. // image1
    30. $video_thumb1 = 'http://i.ytimg.com/vi/'.$video_code.'/1.jpg';
    31.  
    32. // image2
    33.  
    34. $video_thumb2 = 'http://i.ytimg.com/vi/'.$video_code.'/2.jpg';
    35.  
    36. // image3
    37. $video_thumb3 = 'http://i.ytimg.com/vi/'.$video_code.'/3.jpg';
    38.  
    39. //video_description
    40. $video_desc = $data->data->items[0]->description;
    41. ?>
    42.  
    43. <div id="video">Loading the player ...</div>
    44.  
    45. <script type="text/javascript">
    46. jwplayer("video").setup({
    47. flashplayer: "/wp-content/themes/f1/js/player.swf",
    48. file: "<? echo $video_play;?>",
    49. height: 300,
    50. width: 605,
    51. wmode : "transparent",
    52. skin: "/chrome.zip"
    53. });
    54. </script>
    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