how i can make automatic redirect from youtube to my own site

Discussion in 'PHP' started by aloaax, Nov 16, 2011.

  1. #1
    i wanna make my own site like that

    it's rapid youtube code to my site

    example

    http://rapidrelease.info/youtube.php?id=7KCUpeh7DKk
    http://rapidrelease.info/youtube.php?id=URFW9EDeeCw
    http://rapidrelease.info/youtube.php?id=3CBeIc2sqHQ

    http://www.youtube.com/watch?v=7KCUpeh7DKk
    http://www.youtube.com/watch?v=URFW9EDeeCw
    http://www.youtube.com/watch?v=3CBeIc2sqHQ

    just change eny code from youtube like this 3CBeIc2sqHQ
    and but at http://rapidrelease.info/youtube.php?id=XXXXXXX

    it's work eny vedio

    i wanna make the same on my site
     
    aloaax, Nov 16, 2011 IP
  2. Anveto

    Anveto Well-Known Member

    Messages:
    697
    Likes Received:
    40
    Best Answers:
    19
    Trophy Points:
    195
    #2
    Just generate a random string

    <?php
    function generateRandStr($length){
          $randstr = "";
          for($i=0; $i<$length; $i++){
             $randnum = mt_rand(0,9);
             $randstr .= $randnum;
          }
          $query = "SELECT COUNT(*) FROM CodeContent WHERE StringID = '{$randstr}'";
    
        $result = mysql_query($query);
        $row = mysql_fetch_assoc($result);
    
        if ($row['COUNT(*)'] > 0) { // if it already exists, do it again
    
            $randstr = generateRandStr($length);
        }
          return $randstr;
       }
    $string = generateRandStr(11);
    ?>
    PHP:
    and then on your youtube.php page you simply get the id with $_GET

    and then match the string in a database and find the information you want to display or the link you want to redirect to :)
     
    Anveto, Nov 17, 2011 IP
  3. aloaax

    aloaax Peon

    Messages:
    4
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    iam sorry but can u help me how i do that on pic
     
    aloaax, Nov 17, 2011 IP
  4. vlada111

    vlada111 Well-Known Member

    Messages:
    356
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    165
    #4
    Thanks markoy96!
     
    vlada111, Nov 17, 2011 IP
  5. Anveto

    Anveto Well-Known Member

    Messages:
    697
    Likes Received:
    40
    Best Answers:
    19
    Trophy Points:
    195
    #5
    Sorry but i don't understand what you are asking
     
    Anveto, Nov 17, 2011 IP
  6. aloaax

    aloaax Peon

    Messages:
    4
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #6
    http://rapidrelease.info/youtube.php?id=URFW9EDeeCw

    u see this link

    its open youtube vedio

    just i change this code URFW9EDeeCw from URL and write eny video code the vedio open i need to make page like this youtube.php?id=xxxx

    automaticly redirect from youtube to my site

    my domain

    www.xxx.com/youtube.php?id=[write here eny vedio code from youtube]

    and open like this site
    http://rapidrelease.info/youtube.php?id=URFW9EDeeCw
     
    aloaax, Nov 17, 2011 IP
  7. Jesse12

    Jesse12 Member

    Messages:
    360
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    28
    #7
    Its look like you want to display the youtube videos on the website on the basis of the “id” from the query string. But I m not sure from where you get the “id” values i.e. from DB or from third party API?



    But all you need to get the “id” value and passed into the URL with $_REQUEST. Ex. http://rapidrelease.info/youtube.php?id=<?php echo $_REQUEST[‘id’];?>
     
    Jesse12, Nov 19, 2011 IP